Skip to content

Commit

Permalink
Only disableRestoreFocus if isTouch
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-james committed Dec 19, 2024
1 parent ddcf42f commit fdc54c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/HamburgerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ const HamburgerMenu = () => {
setTimeout(() => {
dispatch(toggleSidebar({}))
}, 10)
// The Editables need to ignore the click event and its corresponding blur, fired after all of the touch events.
// There is no click event fired when the sidebar is opened on iOS Safari, but there is one fired when it is closed via hamburger menu. This extraneous click event doesn't
// interfere as long as we want the keyboard to stay closed when users close the sidebar, but if we want to restore focus to an Editable then it will need to be suppressed.
if (isTouch && isSafari()) {
e.preventDefault()
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const Sidebar = () => {
// On iOS Safari, restoring focus works when tapping the backdrop to close the sidebar, but not when tapping the hamburger
// menu to close the sidebar. Hopefully the hamburger menu can be fixed and focus can be restored properly in all cases.
// Until then, letting the backdrop (correctly) restore focus results in inconsistent behavior.
ModalProps={{ disableRestoreFocus: true }}
ModalProps={{ disableRestoreFocus: isTouch }}
SwipeAreaProps={{
style: {
// Set width here since setting style with SwipeAreaProps will override the swipeAreaWidth prop.
Expand Down

0 comments on commit fdc54c0

Please sign in to comment.