-
Notifications
You must be signed in to change notification settings - Fork 88
fix(input-date-picker): no longer close when non-interactive areas are clicked in Safari #12139
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
Merged
anveshmekala
merged 11 commits into
dev
from
anveshmekala/10113-fix-input-date-picker-inconsistent-input
Jun 18, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5816346
fix(input-date-picker): no longer close date-picker in Safari when no…
anveshmekala 2e6f986
remove tabIndex
anveshmekala c3a238f
Merge branch 'dev' into anveshmekala/10113-fix-input-date-picker-inco…
anveshmekala 5fd18fc
add delegatesFocus to inner shadow element
anveshmekala 67007ed
add non-focusable wrapper container
anveshmekala 4c74132
Merge branch 'dev' into anveshmekala/10113-fix-input-date-picker-inco…
anveshmekala f7b589c
cleanup
anveshmekala ffec7ad
remove outline
anveshmekala c9c8723
add comment
anveshmekala fec8d99
refactor
anveshmekala 1d37172
cleanup
anveshmekala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delegatesFocusis causing issue in Safari to focus the first focusable element while clicking on non-interactive areas. date-picker-month-header/date-picker-month didn't enabled delegatesFocus, hence the focus shifts on tobodyelement which is inconsistent with Chrome.Tested alternate solution of adding delegatesFocus onto
date-picker-header&date-picker-header-monthwhich resolves the bug & enables focusing disabled chevrons (which is a common use case with min/max props). Additionally, stray clicks could focus day's similar to #6462.Proposing to remove delegatesFocus here & users can leverage
setFocus( )method instead offocus( ). This isn't a BREAKING CHANGE becausedatePicker.focus( )is not working as expected indate-pickersince the start (https://codepen.io/anvesh-mekala/pen/XJJoKzQ goes back to 2.12.1 version).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great breakdown. One more note, the recommended and supported way to focus our elements is to use
setFocusand notfocus.Also, can you also double-check that
blurandfocusevents occur as expected ondate-picker? IIRC,delegatesFocusaffects this in some cases. If so, this might be considered breaking.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing
delegatestFocusdid invokeblur( )when user clicks on the non-interactive areas of date-picker. To counter this, we need to add a wrapper container indate-pickerwhich renders descendant elements with shadowDOM and delegatesFocus='false'.When delegatesFocus is enabled, any clicks on non-interactive areas should focus the first focusable element as per spec .In date-picker case descendants of date-picker didn't enabled delegatesFocus and safari is invoking a blur event.
Did some digging into HTML spec for delegatesFocus and it doesn't completely answer the use-case we have here with deep nested shadow child elements without delegatesFocus to understand if the issue is browser related as it fails only in Safari. One comment did catch the eye which outlines the proposed spec &
click( )behavior has some leeway due to implementation differences and dependency on User Agent definition of click focusable element .After some 🕵️♂️ & discussions, adding a wrapper container in date-picker would help resolve this issue to register the boundaries of descendants in date-picker. Though this solution doesn't depend on
delegatesFocus, the root cause is related to delegatesFocus specification of clicking non-interactive areas with descendants delegatesFocus set tofalsein Safari.We could always add delegatesFocus on to descendant elements and it will resolve the current issue. Additionally, any click on non-interactive area will shift the focus to the closest element hence causing a focus shift which can hard to reason for end-user.