Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/date-picker/__tests__/RangePicker.test.tsx
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions components/date-picker/demo/select-in-range.md
Expand Up @@ -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')}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tests/shared/focusTest.tsx
Expand Up @@ -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;
Expand Down Expand Up @@ -110,7 +110,7 @@ export default function focusTest(
expect(blurred).toBeTruthy();

fireEvent.blur(getElement(container));
await sleep(0);
await sleep(blurDelay);
expect(onBlur).toHaveBeenCalled();
});

Expand Down