From 0fd9e6ed9554beafec2d2350b758014da705c233 Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Fri, 3 Apr 2020 21:13:42 -0700 Subject: [PATCH 1/2] Fix Picker custom menu widths --- packages/@react-spectrum/picker/src/Picker.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/@react-spectrum/picker/src/Picker.tsx b/packages/@react-spectrum/picker/src/Picker.tsx index c209e14f2f6..f05586b0766 100644 --- a/packages/@react-spectrum/picker/src/Picker.tsx +++ b/packages/@react-spectrum/picker/src/Picker.tsx @@ -123,16 +123,17 @@ function Picker(props: SpectrumPickerProps, ref: DOMRef) { } else { // If quiet, use the default width, otherwise match the width of the button. This can be overridden by the menuWidth prop. // Always have a minimum width of the button width. When quiet, there is an extra offset to add. - let btnWidth = isQuiet ? null : buttonWidth; - let width = menuWidth ? dimensionValue(menuWidth) : btnWidth; - let minWidth = isQuiet ? `calc(${buttonWidth}px + calc(2 * var(--spectrum-dropdown-quiet-offset)))` : buttonWidth; + let width = isQuiet ? null : buttonWidth; + let style = { + ...overlayProps.style, + width: menuWidth ? dimensionValue(menuWidth) : width, + minWidth: isQuiet ? `calc(${buttonWidth}px + calc(2 * var(--spectrum-dropdown-quiet-offset)))` : buttonWidth + }; overlay = ( Date: Fri, 3 Apr 2020 22:00:56 -0700 Subject: [PATCH 2/2] Add comment --- packages/@react-spectrum/picker/src/Picker.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@react-spectrum/picker/src/Picker.tsx b/packages/@react-spectrum/picker/src/Picker.tsx index f05586b0766..8009589627e 100644 --- a/packages/@react-spectrum/picker/src/Picker.tsx +++ b/packages/@react-spectrum/picker/src/Picker.tsx @@ -123,6 +123,7 @@ function Picker(props: SpectrumPickerProps, ref: DOMRef) { } else { // If quiet, use the default width, otherwise match the width of the button. This can be overridden by the menuWidth prop. // Always have a minimum width of the button width. When quiet, there is an extra offset to add. + // Not using style props for this because they don't support `calc`. let width = isQuiet ? null : buttonWidth; let style = { ...overlayProps.style,