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

[pickers] Improve the behaviors when the end date is filled before the start date #12177

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Feb 22, 2024

Fixes #11269

Right now, if you click on the end input of a DateRangePicker and selects a date, is closes the calls onAccept and closes the picker even though you never clicked on the start date.
But if you click on the start input and selects a date, it jumps to the end date and do not closes the picker.

I am not sure how this behavior should inter-play with the defaultRangePosition. Should we consider that when opening the picker through the input equal to defaultRangePosition we only have to select this value and if we open the picker through the other input we have to select both values (not sure how to implement this).
Should we have the same behavior on the DateRangeCalendar when used alone?

@flaviendelangle flaviendelangle added the component: pickers This is the name of the generic UI component, not the React module! label Feb 22, 2024
@flaviendelangle flaviendelangle self-assigned this Feb 22, 2024
if (allowRangeFlip) {
response = { nextSelection: 'start', newRange: [end!, selectedDate] };
} else {
response = { nextSelection: 'start', newRange: [null, selectedDate] };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworked this method to avoid computing truthyResult if it's not needed.

And I did one behavior change here.
Now, if you have a date with only an end date filled, and you click on a date after the end date, you just change the end date and keep editing the start date.

This is more consistent with the mirror scenario for start date.

@mui-bot
Copy link

mui-bot commented Feb 22, 2024

Deploy preview: https://deploy-preview-12177--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 6683004

@flaviendelangle flaviendelangle force-pushed the range-position-end branch 2 times, most recently from 430b415 to 5e75abe Compare February 22, 2024 16:27
@@ -488,65 +521,10 @@ describe('<DesktopDateRangePicker />', () => {
expect(onClose.callCount).to.equal(1);
});

it('should call onClose, onChange with empty value and onAccept with empty value when pressing the "Clear" button', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All those tests (and the equivalent on MobileDateRangePicker.test.tsx) are already handled by testPickerActionBar.tsx

@flaviendelangle flaviendelangle changed the base branch from next to master March 21, 2024 14:09
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 29, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 29, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 29, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DateRangePicker] Properly handle range selection completion when defaultRangePosition="end"
2 participants