Skip to content

Commit 63abfd5

Browse files
authored
fix: preserve min width for numeric popup width
1 parent 1169cb8 commit 63abfd5

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/SelectTrigger.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@ const SelectTrigger: React.ForwardRefRenderFunction<RefTriggerProps, SelectTrigg
137137
const isNumberPopupWidth = typeof popupMatchSelectWidth === 'number';
138138

139139
const stretch = React.useMemo(() => {
140-
if (isNumberPopupWidth) {
141-
return null;
142-
}
143-
144-
return popupMatchSelectWidth === false ? 'minWidth' : 'width';
140+
return popupMatchSelectWidth === false || isNumberPopupWidth ? 'minWidth' : 'width';
145141
}, [popupMatchSelectWidth, isNumberPopupWidth]);
146142

147143
let mergedPopupStyle = popupStyle;

tests/Select.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,22 @@ describe('Select.Basic', () => {
17371737
expect(container.querySelectorAll('.rc-select-item')).toHaveLength(options.length);
17381738
});
17391739

1740+
it('dropdown menu width should not be smaller than trigger when popupMatchSelectWidth is a number', () => {
1741+
const { container } = render(
1742+
<Select style={{ width: 1000 }} popupMatchSelectWidth={500}>
1743+
<Option value={0}>0</Option>
1744+
</Select>,
1745+
);
1746+
1747+
toggleOpen(container);
1748+
1749+
expect(container.querySelector('.rc-select-dropdown')).toHaveStyle({
1750+
minWidth: '1000px',
1751+
width: '500px',
1752+
});
1753+
expect(global.triggerProps.stretch).toBe('minWidth');
1754+
});
1755+
17401756
it('virtual false also no render virtual list', () => {
17411757
const options = [];
17421758
for (let i = 0; i < 99; i += 1) {

0 commit comments

Comments
 (0)