fix: Adjusting the width of dropdown (#18059)
* fix: Adjusting the width of dropdown This will make it so the width of the dropdown will adjust to the longest variable name * fix: Adjusting the width of dropdown Updating font * fix: Adjusting the width of dropdown fix prettierpull/18109/head
parent
97037f84d9
commit
17f4cc14f2
|
@ -93,3 +93,7 @@
|
|||
cursor: grab !important;
|
||||
}
|
||||
}
|
||||
|
||||
.variable-dropdown--item {
|
||||
font-family: $cf-code-font;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,14 @@ class VariableDropdown extends PureComponent<Props> {
|
|||
const dropdownStatus =
|
||||
values.length === 0 ? ComponentStatus.Disabled : ComponentStatus.Default
|
||||
|
||||
const longestItemWidth = Math.floor(
|
||||
values.reduce(function(a, b) {
|
||||
return a.length > b.length ? a : b
|
||||
}, '').length * 8.5
|
||||
)
|
||||
|
||||
const widthLength = Math.max(140, longestItemWidth)
|
||||
|
||||
return (
|
||||
<div className="variable-dropdown">
|
||||
{/* TODO: Add variable description to title attribute when it is ready */}
|
||||
|
@ -62,6 +70,7 @@ class VariableDropdown extends PureComponent<Props> {
|
|||
)}
|
||||
menu={onCollapse => (
|
||||
<Dropdown.Menu
|
||||
style={{width: `${widthLength}px`}}
|
||||
onCollapse={onCollapse}
|
||||
theme={DropdownMenuTheme.Amethyst}
|
||||
>
|
||||
|
@ -74,6 +83,7 @@ class VariableDropdown extends PureComponent<Props> {
|
|||
onClick={this.handleSelect}
|
||||
selected={val === selectedValue}
|
||||
testID="variable-dropdown--item"
|
||||
className="variable-dropdown--item"
|
||||
>
|
||||
{val}
|
||||
</Dropdown.Item>
|
||||
|
|
Loading…
Reference in New Issue