diff --git a/components/Dropdown.js b/components/Dropdown.js index 7ac0795..ea6b68d 100644 --- a/components/Dropdown.js +++ b/components/Dropdown.js @@ -59,10 +59,12 @@ class Dropdown extends Component { render() { const { button, color, list, selected, onChange } = this.props + const minWidth = calcMinWidth(button, selected, list) + return ( it === selected)} itemToString={item => item.name} @@ -73,7 +75,7 @@ class Dropdown extends Component { } } -const renderDropdown = ({ button, color, list, selected }) => ({ +const renderDropdown = ({ button, color, list, minWidth, selected }) => ({ isOpen, highlightedIndex, setHighlightedIndex, @@ -85,10 +87,7 @@ const renderDropdown = ({ button, color, list, selected }) => ({ getItemProps }) => { return ( - + { ) } -function minWidth(isButton, selected, list) { +function calcMinWidth(isButton, selected, list) { const items = isButton ? [...list, selected] : list return items.reduce((max, { name }) => {