From 64c8991476aa56981c012fe1b4bc8d43da5f973d Mon Sep 17 00:00:00 2001 From: Gorka Date: Mon, 30 Sep 2019 12:30:35 +0200 Subject: [PATCH 1/9] DropDown: update width calculations These changes take into consideration if the wide prop is set or not to compute the min width value for the button, it also refactors the way the caret spacing is considered for the rendered placeholder (adds a container with max width) and updates the ref callback to consider the list items instead of the container (which had spacing applied to it) --- src/components/DropDown/DropDown.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/DropDown/DropDown.js b/src/components/DropDown/DropDown.js index 973322fe6..3e75239f0 100644 --- a/src/components/DropDown/DropDown.js +++ b/src/components/DropDown/DropDown.js @@ -123,8 +123,7 @@ const DropDown = React.memo(function DropDown({ if (!el) { return } - // Add 4 GU to accomodate for caret spacing - setPlaceholderMinWidth(el.clientWidth + 4 * GU) + setPlaceholderMinWidth(el.clientWidth) setGetContentWidth(false) }, []) // Re-adjust if the width or items ever change @@ -187,7 +186,7 @@ const DropDown = React.memo(function DropDown({ padding-left: ${2 * GU}px; padding-right: ${1.5 * GU}px; width: ${width || (wide ? '100%' : 'auto')}; - min-width: ${placeholderMinWidth}px; + min-width: ${wide ? 'auto' : `${placeholderMinWidth}px`}; background: ${disabled ? theme.disabled : theme.surface}; color: ${disabled ? theme.disabledContent : theme.surfaceContent}; border: ${disabled ? 0 : 1}px solid @@ -203,7 +202,15 @@ const DropDown = React.memo(function DropDown({ `} {...props} > -