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

[DateRangePciker] When any date is selected and get out of focus and then try to update the year or month it directly focuses on date #15880

Open
Abhid1239 opened this issue Dec 14, 2024 · 4 comments
Labels
bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer

Comments

@Abhid1239
Copy link

Abhid1239 commented Dec 14, 2024

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/run?file=Demo.tsx
  2. Click on any of the date picker
  3. then click on the second date year change
  4. It would get refocused to date of that date picker

This is an issue of focus where it doesn't get applied directly that specific year or month it get's the focused applied to the date of date picker same issue with single date pickers.
The same functionality is present in other react components library

All these library supports date picker year and month direct focus when the dates are filled

[

Screen.Recording.2024-12-14.at.14.30.04.mov

](url)

Current behavior

When any date is selected and then we try to update year or month only we get directly focused to date of the date picker

Expected behavior

When any date is selected and then we try to update year or month is should focus the year and month

Context

Correcting user experience when year selected it should focus the year when it wasn't focused. IF focused it is working correctly but not on focus

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: focus issue in date range pciker

@Abhid1239 Abhid1239 added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 14, 2024
@github-actions github-actions bot added the component: pickers This is the name of the generic UI component, not the React module! label Dec 14, 2024
@noraleonte
Copy link
Contributor

Hey @Abhid1239 👋
Thanks for reporting this. I can confirm there is an issue when opening the picker again, as the focus jumps directly to the first section. After the picker is opened you can focus on the individual sections, but I agree it's not ideal 🤔 I'll add this to our board so we can discuss how to improve the UX here.

@noraleonte noraleonte added design This is about UI or UX design, please involve a designer and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 16, 2024
@Abhid1239
Copy link
Author

Hey @noraleonte, this feature/UX is already correctly handled/present in single date picker. This only arrises in DateRangePicker and SingleDateRangePicker. I think it can be handled by the developer and can be either converted into a bug/feature

@Abhid1239
Copy link
Author

Again after tinkering a bit more and going through the code too.
We actually have a prop called as selectedSections. Where we can specify which section needs to be focused when date is selected. I think here when nothing is selected it should be handled internally (this might be the issue since in the code base it is defaulted to "day" and is causing the issue (from my analysis🤔))

API Reference

selectedSections 'all'| 'day'| 'empty'| 'hours'| 'meridiem'| 'minutes'| 'month'| 'seconds'| 'weekDay'| 'year'| number - The currently selected sections. This prop accepts four formats: 1. If a number is provided, the section at this index will be selected. 2. If a string of type FieldSectionType is provided, the first section with that name will be selected. 3. If "all" is provided, all the sections will be selected. 4. If null is provided, no section will be selected. If not provided, the selected sections will be handled internally.

@noraleonte
Copy link
Contributor

Thanks for looking into it more. I think the problem is that if you click on the input of the picker (when it has a value), it selects the section you clicked on, opens the picker and refocuses the first section of the input by default. I think it's something we need to look into internally 🤔
It's the same if the selectedSection is controlled 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer
Projects
None yet
Development

No branches or pull requests

2 participants