Skip to content

Commit 32506a1

Browse files
authored
fix: fix Select jump (#796)
* fix: fix Select jump * fix: remove display * fix: add test case
1 parent 08757c1 commit 32506a1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/BaseSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ const BaseSelect = React.forwardRef((props: BaseSelectProps, ref: React.Ref<Base
799799
style={{
800800
width: 0,
801801
height: 0,
802-
display: 'flex',
802+
position: 'absolute',
803803
overflow: 'hidden',
804804
opacity: 0,
805805
}}

tests/BaseSelect.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,28 @@ describe('BaseSelect', () => {
3434
fireEvent.click(container.querySelector('a.trigger'));
3535
expect(container.querySelector('div.rc-select-dropdown-hidden')).toBeTruthy();
3636
});
37+
it('customized inputElement style should includes position: absolute', () => {
38+
jest.useFakeTimers();
39+
const { container } = render(
40+
<BaseSelect
41+
prefixCls="rc-select"
42+
OptionList={OptionList}
43+
displayValues={[]}
44+
emptyOptions
45+
id="test"
46+
onDisplayValuesChange={() => {}}
47+
onSearch={() => {}}
48+
searchValue=""
49+
/>,
50+
);
51+
expect(container.querySelector('div.rc-select')).toBeTruthy();
52+
fireEvent.focus(container.querySelector('div.rc-select'));
53+
jest.runAllTimers();
54+
expect(
55+
getComputedStyle(container.querySelector(`span[aria-live=polite]`)).getPropertyValue(
56+
'position',
57+
),
58+
).toBe('absolute');
59+
jest.useRealTimers();
60+
});
3761
});

0 commit comments

Comments
 (0)