Dropdown in iOS Safari cannot be re-opened while focused
See original GitHub issuedownshift
version: 1.31.6
Relevant code or config
button_handleClick = event => {
event.preventDefault()
// handle odd case for Safari and Firefox which
// don't give the button the focus properly.
/* istanbul ignore if (can't reasonably test this) */
if (
this.props.environment.document.activeElement ===
this.props.environment.document.body
) {
event.target.focus()
}
this.toggleMenu({type: Downshift.stateChangeTypes.clickButton})
}
What you did:
In iOS Safari (iPhone 7, iPhone X) the dropdown button was clicked multiple times in succession in order to toggle the menu
What happened:
The menu opened once then closed, then could not be re-opened while the button remained in focus.
Reproduction repository:
This can be reproduced in the official dropdown example - http://downshift.netlify.com/?selectedKind=Examples&selectedStory=dropdown&full=0&addons=1&stories=1&panelRight=0
Problem description:
Focus needs to be removed from the button in order to re-open the menu. This line in the above code appears to cause the issue:
event.target.focus()
This leads to a call to button_handleBlur
which ultimately leaves the menu closed.
Suggested solution:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
In IOS 15 We have facing some dropdown issue
Clear the browser cache of Safari thru the settings. Using Safari, visit the page and add to Home Screen. Launch the Home Screen...
Read more >Safari in ios8 is scrolling screen when fixed elements get focus
Background: I am using a fixed header and an element further down that sticks below it once the user scrolls that far down....
Read more >Disappearing Safari Tabs on iPhone or iPad? How to Find Them
If you have an inkling that some of the tabs you're missing have been inadvertently closed, you can always use the Recently Closed...
Read more >iOS 16 Cheat Sheet: Complete Guide for 2022 | TechRepublic
Safari was demoed for this feature and showed triggering specific tab groups when a Focus Mode is enabled so you're not tempted to...
Read more >iOS 16.2 Has 39 Huge Changes You Need to Know About ...
While I'll be focusing on the new features from an iPhone perspective, ... This action can not be run on Apple Watch, Mac,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve had a bit of a mess around with this in browserstack, and I think @dalehurwitz is correct. It’s also due to the
setTimeout
inside thebutton_handleBlur
.I’ve had success by wrapping the
toggleMenu
call inside asetTimeout
, but it feels like a band-aid for a band-aid. This does however preserve the existing focus behaviour for safari/firefox/chrome, while resolving the bug in iOS.Thanks for confirming @aMollusk!
I’m fine with adding a bit of complexity to the codebase to handle bugs like this. If someone would like to open a PR to fix this that’d be super 😃