mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(select): ensure filter dropdown matches input field width (#38886)
This commit is contained in:
@@ -915,6 +915,38 @@ test('"Select all" does not affect disabled options', async () => {
|
||||
expect(await findSelectValue()).not.toHaveTextContent(options[1].label);
|
||||
});
|
||||
|
||||
test('dropdown takes full width of the select input for multi select', async () => {
|
||||
render(
|
||||
<div style={{ width: '400px' }}>
|
||||
<Select {...defaultProps} mode="multiple" options={OPTIONS} />
|
||||
</div>,
|
||||
);
|
||||
await open();
|
||||
const dropdown = document.querySelector(
|
||||
'.ant-select-dropdown',
|
||||
) as HTMLElement;
|
||||
expect(dropdown).toBeInTheDocument();
|
||||
// When popupMatchSelectWidth is true, antd dynamically matches the
|
||||
// trigger width and does not set a fixed inline width on the dropdown.
|
||||
const widthValue = parseInt(dropdown.style.width, 10);
|
||||
expect(Number.isNaN(widthValue) || widthValue === 0).toBe(true);
|
||||
});
|
||||
|
||||
test('dropdown takes full width of the select input for single select', async () => {
|
||||
render(
|
||||
<div style={{ width: '400px' }}>
|
||||
<Select {...defaultProps} mode="single" options={OPTIONS} />
|
||||
</div>,
|
||||
);
|
||||
await open();
|
||||
const dropdown = document.querySelector(
|
||||
'.ant-select-dropdown',
|
||||
) as HTMLElement;
|
||||
expect(dropdown).toBeInTheDocument();
|
||||
const widthValue = parseInt(dropdown.style.width, 10);
|
||||
expect(Number.isNaN(widthValue) || widthValue === 0).toBe(true);
|
||||
});
|
||||
|
||||
test('does not fire onChange when searching but no selection', async () => {
|
||||
const onChange = jest.fn();
|
||||
render(
|
||||
|
||||
@@ -777,7 +777,7 @@ const Select = forwardRef(
|
||||
options={visibleOptions}
|
||||
optionRender={option => <Space>{option.label || option.value}</Space>}
|
||||
oneLine={oneLine}
|
||||
popupMatchSelectWidth={selectAllEnabled ? 168 : true}
|
||||
popupMatchSelectWidth
|
||||
css={props.css}
|
||||
dropdownAlign={DROPDOWN_ALIGN_BOTTOM}
|
||||
{...props}
|
||||
|
||||
Reference in New Issue
Block a user