-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: customized inputElement should not trigger close when mousedown …
…trigger (#761) * fix: customized trigger should not trigger close when mousedown trigger * chore: code clean * fix: null check
- Loading branch information
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import BaseSelect from '../src/BaseSelect'; | ||
import { forwardRef } from 'react'; | ||
import type { OptionListProps, RefOptionListProps } from '@/OptionList'; | ||
|
||
const OptionList = forwardRef<RefOptionListProps, OptionListProps>(() => ( | ||
<div className="popup">Popup</div> | ||
)); | ||
|
||
describe('BaseSelect', () => { | ||
it('customized inputElement should trigger popup properly', () => { | ||
const { container } = render( | ||
<BaseSelect | ||
prefixCls="rc-select" | ||
getRawInputElement={() => ( | ||
<a className="trigger" href="#"> | ||
trigger | ||
</a> | ||
)} | ||
OptionList={OptionList} | ||
displayValues={[]} | ||
emptyOptions | ||
id="test" | ||
onDisplayValuesChange={() => {}} | ||
onSearch={() => {}} | ||
searchValue="" | ||
/>, | ||
); | ||
expect(container.querySelector('div.popup')).toBeFalsy(); | ||
fireEvent.click(container.querySelector('a.trigger')); | ||
expect(container.querySelector('div.popup')).toBeTruthy(); | ||
fireEvent.mouseDown(container.querySelector('a.trigger')); | ||
expect(container.querySelector('div.rc-select-dropdown-hidden')).toBeFalsy(); | ||
fireEvent.click(container.querySelector('a.trigger')); | ||
expect(container.querySelector('div.rc-select-dropdown-hidden')).toBeTruthy(); | ||
}); | ||
}); |
fe0fbd9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
select – ./
select-git-master-react-component.vercel.app
select-react-component.vercel.app
select.vercel.app