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.

onBlur behaviour is affected by "touch capabilities"

See original GitHub issue

Are you reporting a bug or runtime error?

That’s not really a bug, and not an error - this is a not correct behavior.

There is an option - blurInputOnSelect

  • blurInputOnSelect: isTouchCapable(),

and the effect of it quite simple:

  selectOption = (newValue: OptionType) => {
    ....
    if (blurInputOnSelect) {
      this.blurInput();
    }

Problems

  1. Should it be delayed? In normal conditions there are two different events (click/change, blur) comes one after another with a little “gap” between them. But in this case - there is no gap. This results into some differences in the “state management” - blur evens is reported too soon - before the change(or select) event is finishing propagation (state change applied back to the component). Probably onBlur should be called in setTimeout, or at least a Promise

  2. Should it even exists?
    For all “touch devices”, windows 10 on hybrid devices included, or only when select is caused by “touch” event? Probably here we should check touch event, and execute blur only there, but not as a part of selectOption

  3. Is it a real problem? Yes, it is. We run into it twice this year, causing SEV1s both times.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

1reaction
tstelzercommented, Aug 27, 2019

Yup, though we’re using setTimeout(f, 0) instead of setImmediate(f).

1reaction
tstelzercommented, Aug 27, 2019

I believe we are having issues stemming from this as well, on touch devices the onBlur triggers before onChange, sometimes, which prevents the change event entirely.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Element: blur event - Web APIs | MDN
The opposite of blur is the focus event, which fires when the element has received focus. The blur event is not cancelable. Syntax....
Read more >
onclick() and onblur() ordering issue - javascript - Stack Overflow
Because onmousedown() fires before onblur() , the flag will be set in onblur() if one of the menu divs was clicked, but not...
Read more >
Accessible JavaScript - JavaScript Event Handlers - WebAIM
One might use onfocus (or focus or focusin events) and onblur (or blur or focusout events) when the keyboard is used to navigate...
Read more >
Pointer Events - W3C
The features in this specification extend or modify those found in Pointer ... Declaring candidate regions for default touch behaviors.
Read more >
Touch/pointer events test results - GitHub Pages
This behavior is inconsistent with other implementations (as noted above, the result is usually touchstart , a few touchmove events, ...
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