Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't unfocus on mobile #32

Closed
Haroenv opened this issue Jul 27, 2017 · 15 comments · Fixed by #50
Closed

Can't unfocus on mobile #32

Haroenv opened this issue Jul 27, 2017 · 15 comments · Fixed by #50

Comments

@Haroenv
Copy link
Contributor

Haroenv commented Jul 27, 2017

  • react-autocompletely version:
  • node version:
  • npm (or yarn) version:

Relevant code or config

https://codesandbox.io/s/9rWEmzEv8

What you did:

Open it on an iPhone, try to press "done", but it doesn't dismiss the focusing

What happened:

Input is permanently focused, not even the url bar is accessible. Can get the focus back out of it when pressing refresh only

Reproduction repository:

https://codesandbox.io/s/9rWEmzEv8

Problem description:

Suggested solution:

Allow the input to blur

@kentcdodds
Copy link
Member

I cannot reproduce this on my Android phone. Are you sure it's a problem? Maybe something it's only an ios issue?

2017_07_27_00_49_57

@FezVrasta
Copy link
Contributor

I can reproduce it on iOS on both Chrome and Safari. The input seems to keep focus and the keyboard can't be closed.

@Haroenv
Copy link
Contributor Author

Haroenv commented Jul 27, 2017

2017-07-27 13_23_26

Here's a reproducible example in the iOS simulator, might be related to how Safari deals with blurring?

@kentcdodds
Copy link
Member

kentcdodds commented Jul 27, 2017

Oh, that's odd. And that's how it works on native (no simulated) iOS as well?

We definitely want to fix that! Could you dig into it a little bit?

@FezVrasta
Copy link
Contributor

I tested only on real device so I'd say "yes"

@dashed
Copy link
Contributor

dashed commented Jul 27, 2017

Interesting. I can confirm this issue.

@kentcdodds
Copy link
Member

Alrighty! Who wants to fix it? 😄

@joao-alberto
Copy link
Contributor

@kentcdodds I want 🤘

@dashed
Copy link
Contributor

dashed commented Jul 28, 2017

I skimmed through this. The bug seems to be resolved when commenting this line out: https://github.com/paypal/react-autocompletely/blob/008129dca3da8ef7e118fd1bbc93c7cad55dc6d5/src/input.js#L77

When the input is blurred, handleBlur is called, which then calls this.autocomplete.reset(), which then calls this.input.reset().

Im guessing moveCursorToTheEnd re-focuses the input element. On my iphone device, attempting to dismiss the input box actually flickers the keyboard (i.e. sliding down and back up).

You can even see this in action in the gif at: #32 (comment)

FYI, I debugged this in Safari.


@kentcdodds what was the reason for moving the cursor to the end after resetting?

@psicotropicos I'm wondering if you've reached similar findings. Since you've called dibs on this, I'd let you PR this if this is the proper fix 👍

@joao-alberto
Copy link
Contributor

@dashed This was the same solution I found so far.
I'm studying the rest of the code to understand the reason for moving the cursor to the end

@kentcdodds
Copy link
Member

You know, I think that we probably don't need that. At least not in the core library. People could implement it themselves if they need. Let's remove that code 👍 Thanks!

@kentcdodds
Copy link
Member

Who wants to do that?

@joao-alberto
Copy link
Contributor

I will send the PR

@joao-alberto
Copy link
Contributor

joao-alberto commented Jul 28, 2017

Done in #46
Thank you very much @dashed 🤘

@kentcdodds
Copy link
Member

This has been fixed. I'll push another beta release as soon as I get the rest of the PRs merged.

dashed added a commit to dashed/react-autocompletely that referenced this issue Jul 28, 2017
kentcdodds pushed a commit that referenced this issue Jul 28, 2017
* Fixes #32

* remove moveCursorToTheEnd

* remove calls to input.reset()

* remove moveCursorToTheEnd ref
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants