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

prevent keyboard from opening automaticaly #3526

Closed
LiranBri opened this issue Apr 27, 2019 · 14 comments
Closed

prevent keyboard from opening automaticaly #3526

LiranBri opened this issue Apr 27, 2019 · 14 comments
Labels
issue/reviewed Issue has recently been reviewed (mid-2020)

Comments

@LiranBri
Copy link

Hello,
when the user press the component when filter is enabled, two things happens:

  1. options are rendered so he can choose from
  2. keyboard is opened so he can type to filter

is it possible to disable #2, so it will happen only when user clicks again?
if not, is it possible to auto hide the keyboard when he starts scrolling through the options?

on small mobile devices, the keyboard hides the options and user must manually close the keyboard (on iphone i think its not even possible)

@crobinson42
Copy link

@JedWatson @LiranBri I'm in the same boat - I have posted a stackoverflow question here to accomplish this: https://stackoverflow.com/questions/57733799/react-select-dont-focus-input-when-opening-options-list

@andrewringler
Copy link

Here is a screenshot of what this currently looks like on IOS 13.1.2, Safari iPhone SE, with a react-select inside a modal dialog about 1/3 of the way down the page.

IOS_ReactSelect

As @LiranBri said there is actually no way to hide the IOS keyboard without disabling the control, so we are limited to just seeing however many options fit above the IOS keyboard.

I am not sure what a reasonable solution is? On non touch devices react-select lets you click into the control on the blinking cursor to enter typing mode, it looks like on touch devices react-select enters typing mode immediately on control focus? Perhaps we should have a keyboard icon or something inside the control to enter typing mode instead on touch devices?

@Vadorequest
Copy link

Vadorequest commented Jan 4, 2020

I'm encountering the same issue, and I'd love an option to avoid the keyboard to open automatically when focusing the input as well. (option 2)

It's a blocker for my app, because I rely on onMenuClose event to sync the selected choices (they're not sync on onChange event), and it's broken on mobile because the onMenuClose event isn't triggered even though the menu is visually closed once selecting a choice in the menu. (it's another issue, but if the menu would have been closable by default it could have been a workaround for me)

@seba9999
Copy link

I'm facing this too ... :'(

IMO it should trigger the list when users click the arrow and open the list PLUS focusing the input ( and btw open the keyboard ) if the user click the input part of the react-select :)

@Methuselah96
Copy link
Collaborator

Methuselah96 commented Nov 14, 2020

I've started a fork of react-select. Feel free to resubmit this issue on the fork and/or submit a PR to resolve this issue on the fork and we can get it merged and released.

EDIT: 🎉 I've archived the fork now that we've got some momentum in this repo and Jed is involved again. Sorry for the disturbance!

@ebonow
Copy link
Collaborator

ebonow commented Dec 7, 2020

Greetings @LiranBri @seba9999 @Vadorequest @crobinson @andrewringler,

I may have actually inadvertently solved this with my response to this issue: #4279 (comment)

It seems that a user had this very same idea and was trying to remove the DummyInput and understand how to render the menu without it. I think the response was fairly elaborate if you are curious about the how it all works.

Long story short, as long you can render a control with at least one-focusable item, open the menu, and give focus to that item, the react-select menu will operate as expected

Here is a working demo with one button giving itself focus and enabling the menu arrow commands.

I will close this issue for now given the age of this, but I can re-open it if there are problems/concerns/questions.

@ebonow ebonow closed this as completed Dec 7, 2020
@crobinson42
Copy link

@ebonow I wouldn't say this issue is closed. I would vote that this functionality be added as some sort of prop to the component, ie: inputFocusOnClick={false}

@ebonow
Copy link
Collaborator

ebonow commented Dec 7, 2020

@crobinson42 I think you make a good point, though I don't believe we would want to add another prop as much as we'd want to replace the DummyInput to entirely avoid this situation for mobile users when isSearchable is false.

I'll add this as a discussion point with the team and reopen this issue.

@ebonow
Copy link
Collaborator

ebonow commented Dec 18, 2020

Greetings everyone,

I am unable to reproduce this issue as long as the prop isSearchable is set to false. Testing on the homepage of react-select allows the user to toggle Searchable.

When Searchable is true, I see the keyboard as expected.
Screen Shot 2020-12-18 at 5 43 00 PMScreen Shot 2020-12-18 at 5 43 10 PM

When Searchable is unchecked, I do not see a keyboard as expected.
Screen Shot 2020-12-18 at 5 31 59 PMScreen Shot 2020-12-18 at 5 31 47 PM

If anyone can create a reproducible demo of this behavior, we would gladly reopen this ticket, but as it stands this does not appear to be still an issue.

@ebonow ebonow closed this as completed Dec 18, 2020
@diegys
Copy link

diegys commented Jul 7, 2021

What about when you don't want to disable the search? focusInputOnMenuOpen prop would be nice.

Cedev added a commit to Cedev/react-select that referenced this issue Jan 28, 2022
Adds two new properties to control focus that would open a potentially unnecessary mobile keyboard

 * blurInputOnClear: true (default false) stops keyboard focus when clearing options
 * focusInputOnMenuOpen: false (default true) stops keyboard focus when opening the menu via the dropdown
@Vuliniar
Copy link

As @diegys suggested, it would be great to have such a prop that will 'softly' hide the keyboard initially on the menu open.

@obrunaodev
Copy link

SOLUTION
Set the prop isSearchable to false.

    <ReactSelect
      isSearchable={false}
      classNames={classNames}
      unstyled
      placeholder={placeholder}
      onChange={({ value }) => handleChange(value)}
      options={options}
      classNamePrefix=react-select"
    />

@filarrro
Copy link

filarrro commented Sep 4, 2023

@ebonow I think that the author wanted a searchable select that doesn't focus the search input automatically (on menu open).

isSearchable prop allow to have a select working like:

  • when set to false -> normal select that on click opens a menu with option list (no keyboard apears)
  • when set to true -> autocomplete select that on click opens a menu with option list and opens keyboard on mobile devices

Is there a way to have a searchable/autocomplete select that on click opens a menu with option list AND does not open the keyboard?
The use case is e.g. when we want to have an "external" search input that appears above the option list on mobile, see attached screenshot. In this case I want a keyboard to be show only when input above the list is focused, not immediately after opening a menu.

Screenshot 2023-09-04 at 15 32 03

UPDATE:
I've achieved what I needed with this code example:
https://codesandbox.io/s/react-select-input-in-menulist-forked-sw8wnq?file=/example.js

You can find more info in: #3111
in this comment #3111 (comment)

@rever96
Copy link

rever96 commented Nov 11, 2023

pls add this feature.
We want the select to be searchable but to choose when the keyboard appear on mobile device:

  • onfocus (the current one)
  • when user click the input again after he focussed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/reviewed Issue has recently been reviewed (mid-2020)
Projects
None yet
Development

No branches or pull requests