fix: onBlur gets triggered when selecting date in RangePicker (#38411)

* feat: update picker version

* Update package.json

Co-authored-by: afc163 <afc163@gmail.com>

* feat: update test case

* feat: RangePicker blurDelay

Co-authored-by: tangwenhui <tangwenhui@rd.netease.com>
Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
kiner-tang(文辉) 2022-11-12 16:32:41 +08:00 committed by GitHub
parent 59a3168ff0
commit 796e8e16bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import { closePicker, openPicker, selectCell } from './utils';
const { RangePicker } = DatePicker;
describe('RangePicker', () => {
focusTest(RangePicker, { refFocus: true });
focusTest(RangePicker, { refFocus: true, blurDelay: 110 });
beforeEach(() => {
setMockDate();

View File

@ -50,6 +50,7 @@ const App: React.FC = () => {
onCalendarChange={val => setDates(val)}
onChange={val => setValue(val)}
onOpenChange={onOpenChange}
onBlur={() => console.log('blur has been triggered')}
/>
);
};

View File

@ -139,7 +139,7 @@
"rc-motion": "^2.6.1",
"rc-notification": "~4.6.0",
"rc-pagination": "~3.2.0",
"rc-picker": "~2.6.11",
"rc-picker": "~2.7.0",
"rc-progress": "~3.4.1",
"rc-rate": "~2.9.0",
"rc-resize-observer": "^1.2.0",

View File

@ -4,7 +4,7 @@ import { sleep, render, fireEvent } from '../utils';
// eslint-disable-next-line jest/no-export
export default function focusTest(
Component: React.ComponentType<any>,
{ refFocus = false, testLib = false } = {},
{ refFocus = false, testLib = false, blurDelay = 0 } = {},
) {
describe('focus and blur', () => {
let focused = false;
@ -110,7 +110,7 @@ export default function focusTest(
expect(blurred).toBeTruthy();
fireEvent.blur(getElement(container));
await sleep(0);
await sleep(blurDelay);
expect(onBlur).toHaveBeenCalled();
});