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.

Can't type after clearing select on mobile devices

See original GitHub issue

Problem

User can’t type after clearing a select on mobile devices.

We managed to reproduce this on mobile devices only (not even simulating a device). So far, we tested this on iOS, both Chrome and Safari.

We noticed this in our app first and also managed to reproduce in the react-select demo website and on CodeSandbox (see steps below).

Steps to reproduce

Screen captures

From the Sandbox link

https://youtu.be/nBLZDUqcivs

From the documentation site

https://youtu.be/fdN97WsWNkE

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

2reactions
simonflkcommented, May 15, 2019

Well, I did a little investigation, and I have a workaround which meets my needs. I would like to understand more of what’s going wrong and fix it properly, but I don’t have a Mac I can use for debugging and I can’t get browserstack to load sourcemaps for some reason. Despite what you said @amireynoso, about only seeing this on actual devices, I am seeing this on browserstack also (which afaiu uses the Xcode iOS simulator).

You can check out my workaround here… sandbox: https://23k27kk8p.codesandbox.io/ code: https://codesandbox.io/s/23k27kk8p

Essentially it boils down to watching for a change with an empty value, and manually focusing the select.

This is a diff from the original sandbox with the key changes:

--- /home/simon/tmp/example.js.orig		2019-05-15 10:04:44.220625289 +0200
+++ /home/simon/tmp/example.js.forked	2019-05-15 10:08:08.693652368 +0200
@@ -3,9 +3,17 @@
 import { colourOptions } from "./docs/data";
 
 export default class SingleSelect extends Component<*, State> {
+  handleChange = change => {
+    if (!change && this.selectRef) {
+      this.selectRef.focus();
+    }
+  }
+
   render() {
     return (
       <Select
+        ref={select => this.selectRef = select}
+        onChange={this.handleChange}
         className="basic-single"
         classNamePrefix="select"
         defaultValue={colourOptions[0]}

As far as my investigation went, I found quite easily where the event handlers are added to the <ClearIndicator/> component: https://github.com/JedWatson/react-select/blob/b37edfd3c71d37a41baf0d770031c26c92813e7c/src/Select.js#L1539-L1551

we should be hitting that touchend event handler on iOS, which delegates to the mousedown event handler as seen here: https://github.com/JedWatson/react-select/blob/b37edfd3c71d37a41baf0d770031c26c92813e7c/src/Select.js#L1060-L1064

and in that event handler, we see that the input is cleared, event propagation is stopped, and the input should be focused on the next frame: https://github.com/JedWatson/react-select/blob/b37edfd3c71d37a41baf0d770031c26c92813e7c/src/Select.js#L941-L950

As I said yesterday, it appears that the input is being focused, as document.activeElement is set to the input even when typing is disabled. And unless browserstack is lying to me, it looks like the input is not disabled or readonly.

At first I thought it might be a controlled input with a missing/broken onChange/onKeyDown event handler. But I think that in those cases you would still see a caret. But I don’t think that happens here.

Maybe @JedWatson or other maintainers (?) can shed some light.

2reactions
simonflkcommented, May 14, 2019

I’m having the same problem. Seems that if I focus another field, and then re-focus the cleared select, it works ok.

document.activeElement looks the same in both cases, so it looks like it’s focusing the right input. If I figure out a fix or workaround, I’ll update this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select, cut, copy, and paste text on iPhone - Apple Support
Select and edit text ... To select text, do any of the following: ... After selecting the text you want to revise, you...
Read more >
Keyboard is not working on Galaxy phone or tablet - Samsung
Clear the keyboard's cache and data. · Navigate to and open Settings, and then scroll and tap Apps. · Tap the sort icon...
Read more >
I can not write any value from input on mobile device
In this case i.element is also touched when you touch the text input. l.preventDefault() is preventing the default behavior on i.element and all ......
Read more >
Fix problems with Gboard - Android - Google Support
If Gboard switches to another keyboard, you can switch it back. On your Android phone or tablet, open any app that you can...
Read more >
Android Messages App Not Working? 12 Fixes to Try
Go to Settings > Apps & notifications > Advanced > Default apps > SMS app and select Messages. 4. Clear the Messages App...
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