From 8a814beed341be5f721e9f6c43c3edaa1438867d Mon Sep 17 00:00:00 2001 From: Jake Dexheimer Date: Sun, 18 Mar 2018 12:02:31 -0500 Subject: [PATCH] Fix dropdown minWidth issue --- components/Dropdown.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 }) => {