Dropdown select does not work on iOS (safari)
See original GitHub issuedownshift
version: http://downshift.netlify.com/node
version:npm
(oryarn
) version:
What you did: Tried dropdown example
What happened: I can open dropdown by clicking button, but I can’t select any other item
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (8 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 >Select Dropdown is not working on iPhone iOS version 14.6 in ...
I'm not sure why the drodown is not working on iPhone iOS 14.6 safari browser when with fastclick.js include.
Read more >Dropdown select not working on mobile Safari (iOS) - Select2
I use select2 in a plugin on WordPress, and a user reported that the select2 dropdown has to be touched (clicked) twice in...
Read more >Drop-down menu not working in Safari - Search & Filter Support
It may be, if the device is an Apple, that the dropbown boxes need making in to 'comboboxes' (there is an option in...
Read more >Safari's dropdown menu not working on brand new iphone ...
Safari's dropdown menu not working on brand new iphone (tried updating ios but didn't work) ... Scroll to the name. Tap the name...
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
So I finally had some time to look into this. While I thought this was related to the original issue, I now realised that my problem might not be what @vonwao intended. If that is the case, I’m sorry for stealing this issue.
My problem exists when the toggle button is a
<button>
element. When I press the toggle button the first time, it opens the menu as it should. I can select other items in the list, or press anywhere else on the page to trigger the blur event and close the menu. However, if I instead press the toggle button again (so first toggle button to open, then toggle button to close), the menu stays open. This happens in Safari on iOS. I tried it out using the Xcode simulator on an iPhone 6 running iOS 9.The problem seems to be that Safari on iOS triggers a blur event before the onClick event, if the button was manually focused. This causes, as I posted in a comment above, that the menu is first reset (isOpen = false) and then toggled (isOpen = true). I think the desired behaviour is that the menu should only be toggled (isOpen = false).
To fix this, I found a solution where we can store the blur event target and compare it to the active selection and see if it’s the same element that is focused again. In that case we shouldn’t trigger the blur action.
This code example would solve this problem:
Note that this is only a problem when the toggle button is a
<button>
element.Another possible workaround (that could have some more side effects) is to use
preventDownshiftDefault
on the onBlur method:I’d happily create a pull request if you think my code example is a good solution for this.
Sorry, it was my issue: I did not use
getMenuProps
andtargetWithinDownshift(event.target, false)
returnfalse
, so it was interpreted as outside click.