Browse Source

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>
pull/38526/head
kiner-tang(文辉) 2 years ago
committed by GitHub
parent
commit
796e8e16bf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/date-picker/__tests__/RangePicker.test.tsx
  2. 1
      components/date-picker/demo/select-in-range.md
  3. 2
      package.json
  4. 4
      tests/shared/focusTest.tsx

2
components/date-picker/__tests__/RangePicker.test.tsx

@ -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();

1
components/date-picker/demo/select-in-range.md

@ -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')}
/>
);
};

2
package.json

@ -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",

4
tests/shared/focusTest.tsx

@ -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();
});

Loading…
Cancel
Save