-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[StaticDatePicker] The year view on StaticDatePicker
does not auto scroll to current year
#4601
Comments
The pickers inside a panel are automatically focusing the current year when mounting the year view, not the static panels. If in your app, this focus is not problematic, you can just add the But I think we should not rely on the focus to scroll to the current view and scroll even when the |
Adding this in useEnhancedEffect(() => {
const currentYearDOMNode = ownRef.current!.querySelector<HTMLButtonElement>(`button[data-current-year="1"]`)
if (!currentYearDOMNode) {
return
}
currentYearDOMNode.scrollIntoView({ block: 'center' })
}, [currentYear]) |
Why do you think we should not rely on the focus to manage the scroll? I had a look at how I'm not sure making components visually work without the correct focus state is a good practice for accessibility. For me setting |
When you use
|
I never met an interface with year picker opened by default but yes it should work in this configuration. So the proposed code solves this issue and we have a new one:
About the support of scroll API, you have a workaround in Core using |
Indeed |
The use case is very specific, it's when you have a static date picker opened by default to the https://codesandbox.io/s/date-and-time-pickers-forked-yqmdxr?file=/src/App.tsx If it is opened by default to the |
Our UI only allows to set a month, e.g. to allow a time range from January to March (1st quarter of the year). |
StaticDatePicker
does not auto scroll to current year
Unfortunately it doesn't work when |
@trypton Could you open a new issue to describe it? |
@trypton Hey , did you find a solution for it? i have added a maxDate to 2008 Jan 31 but it isn't focused/highlighted on it and it also does not auto scroll to it. |
I have the same issue @bdamor5 , if I use |
Duplicates
Latest version
Current behavior 😯
When opening the year view of a Standalone Date Picker, the currently selected year is not revealed. I have to scroll down to see the currently selected year. This is inconsistent with the Date Picker component where when opening the year view, the current year is automatically scrolled to.
Date Picker:
Standalone Date Picker:
Expected behavior 🤔
The currently selected year should be revealed in the StandaloneDatePicker.
Steps to reproduce 🕹
Steps:
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
Order ID 💳 (optional)
#27566
The text was updated successfully, but these errors were encountered: