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: Picker shouldn't autoselect values on picking dates in different picker panel mode that the original picker mode #788

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/PickerInput/SinglePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ function Picker<DateType extends object = any>(
const nextValues = multiple ? toggleDates(getCalendarValue(), date) : [date];

// Only trigger calendar event but not update internal `calendarValue` state
triggerCalendarChange(nextValues);
if(internalPicker === internalMode) {
triggerCalendarChange(nextValues);
}

// >>> Trigger next active if !needConfirm
// Fully logic check `useRangeValue` hook
Expand Down
14 changes: 14 additions & 0 deletions tests/picker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,20 @@ describe('Picker.Basic', () => {
expect(document.querySelector('.rc-picker-date-panel')).toBeTruthy();
});

it('date -> year -> month -> date: Selecting date when panel is different than the picker typ shouldn\'t auto-select dates: date -> year -> month -> date', () => {
const { container } = render(<DayPicker />);
openPicker(container);
fireEvent.click(document.querySelector('.rc-picker-year-btn'));

expect(document.querySelector('input').value).toEqual('');
selectCell(1990);
expect(document.querySelector('input').value).toEqual('');
selectCell('Jan');
expect(document.querySelector('input').value).toEqual('');
selectCell(3);
expect(document.querySelector('input').value).toEqual('1990-01-03');
});

it('time', () => {
const onChange = jest.fn();
const onOk = jest.fn();
Expand Down
Loading