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

[YearPicker] Allows to revers year order #6759

Closed
2 tasks done
sakulstra opened this issue Nov 6, 2022 · 7 comments
Closed
2 tasks done

[YearPicker] Allows to revers year order #6759

sakulstra opened this issue Nov 6, 2022 · 7 comments
Labels
component: DatePicker The React component. component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature

Comments

@sakulstra
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

It would be great if i was able to render years in the opposite direction (new to old).

Examples 🌈

In an app i'm currently working on we need peoples birthday, and expect them to be between 18 and 90 years old.
When setting DatePicker minDate and maxDate accordingly the input will render sth like
image

Which is a bit weird as I'd expect the sorting to be the other way around.
Therefore it would be nice if i could supply a flag or add some custom behavior for the Year selection.


On a sidenote, when selecting sth like a "birthday", there's not really any need for a DateLibrary, as the output date is not a "real date" bot more of a time-zone unaware string. I think there's no way to actually use this ui component without a date library, but would be good if there was.

Motivation 🔦

Currently this input is confusing for users as they have to scroll a lot.

Order ID 💳 (optional)

No response

@sakulstra sakulstra added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 6, 2022
@zannager zannager added the component: pickers This is the name of the generic UI component, not the React module! label Nov 7, 2022
@alexfauquette alexfauquette changed the title DatePicker reversed years [YearPicker] Allows to revers year order Nov 7, 2022
@alexfauquette alexfauquette added component: DatePicker The React component. enhancement This is not a bug, nor a new feature priority: low and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 7, 2022
@alexfauquette
Copy link
Member

About birthdays, pickers are not the best options. We have an issue on this topic if you're interested in: #5021

I tried to do a CSS revert, but it's breaking the keyboard navigation. The modification will have to be done by a prop in the YerPicker

@flaviendelangle
Copy link
Member

Currently this input is confusing for users as they have to scroll a lot.

In the last versions, I think we are automatically scrolling to today's year, which solves this part of the problem.

@sakulstra
Copy link
Author

@alexfauquette thx for the comment. After reading this seems like a good idea to me to just change to 3 inputs 😅

@flaviendelangle I think this feature doesn't work very well.
When your min/max range don't include the current year the "topbar" will show the current year which is not selectable (like in the screenshot above) and nothing will be selected/scrolled.

@flaviendelangle
Copy link
Member

When your min/max range don't include the current year the "topbar" will show the current year which is not selectable (like in the screenshot above) and nothing will be selected/scrolled.

In which case do you have a selected year that is not selectable ?
We might not handle this use case correctly indeed

@sakulstra
Copy link
Author

sakulstra commented Nov 7, 2022

@flaviendelangle In the example above i have

minDate={dayjs().subtract(90, 'years')}
maxDate={dayjs().subtract(18, 'years')}

Which I think will via useNow https://github.com/mui/mui-x/blob/next/packages/x-date-pickers/src/internals/hooks/useUtils.ts#L49 default to the current Year which is why in the screenshot provided above #6759 (comment) although the current Year is not within the selectable range has 2022 in the "topbar". And as 2022 is selected, the autoscroll doesn't work as there's no 2022 to scroll to.

@LukasTy
Copy link
Member

LukasTy commented Jan 9, 2025

This is already possible with the yearsOrder="desc" prop introduced by #11780.

@LukasTy LukasTy closed this as completed Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@sakulstra How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: DatePicker The React component. component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

No branches or pull requests

6 participants