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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
5 additions and
4 deletions
-
components/date-picker/__tests__/RangePicker.test.tsx
-
components/date-picker/demo/select-in-range.md
-
package.json
-
tests/shared/focusTest.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(); |
|
|
|
|
|
@ -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')} |
|
|
|
/> |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
@ -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,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(); |
|
|
|
}); |
|
|
|
|
|
|
|