Lost focus in chrome when previousMonth button is disabled #1676
-
Bug descriptionWhen using a calendar with a set fromDate, the previous month button will get disabled when you arrive at the earliest possible month. When you navigate to the earliest possible month using this button, chrome will fire a blur/focusout event that unfocuses from the entire calendar (Firefox does not). This poses an issue if you have the calendar in some kind of popper that closes on blur, causing the popper to close when you navigate to the earliest possible month. To reproduceSandbox - pardon the event code to exemplify the bug Steps
Expected behaviorThis is more of a chrome issue, but I was wondering what your thoughts are on doing something to maintain the focus on the calendar. Probably something along the lines of moving the focus before disabling the button. Additional contextWhatever you decide, let me know your thoughts. Or if you think theres a workaround that I could apply on the implementation side of things |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Interesting bug. Basically, it seems DayPicker is unfocusing its stuff and then Chrome fires a document |
Beta Was this translation helpful? Give feedback.
-
It looks like the issue is in only Chrome, where the focusout Have you considered to use a "focus trap"? Here is an implementation working with chrome too: |
Beta Was this translation helpful? Give feedback.
-
I hadn't! Thanks for taking the time to look into this. I think a focus trap would suit the need perfectly here! I'm happy enough with that solution that we can close this if you'd like! |
Beta Was this translation helpful? Give feedback.
It looks like the issue is in only Chrome, where the focusout
targetElement
works differently from other browsers. Your app is set to hide the calendar according on focusout, and somehow you enter this bug.Have you considered to use a "focus trap"? Here is an implementation working with chrome too:
https://codesandbox.io/s/react-day-picker-dialog-iyizc0