question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dropdown in iOS Safari cannot be re-opened while focused

See original GitHub issue
  • downshift 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aMolluskcommented, Apr 18, 2018

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 the button_handleBlur.

I’ve had success by wrapping the toggleMenu call inside a setTimeout, 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.

0reactions
kentcdoddscommented, Apr 18, 2018

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found