Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-select don't show keyboard on mobile devices and prevent zoom

I'm using React-Select version 2.4.2. Testing on iOS Chrome, Firefox, Safari.

I have gone through the documentation but cannot find the correct prop to pass for this to just happen.

I want the menu to show on mobile, but not the keyboard, or any iOS native footer. Toggling the isDisabled doesn't work, of course, since it disables the entire input and select menu.

Flipping the "searchable" prop to false DOES in fact disable the keyboard, BUT shows a footer with "Done" on Safari and Firefox, and an "X" on Chrome.

Ideally, I could just disable the input but still allow for the touch selection of the options.

Example code:

    <Select
        value={selectedOption}
        options={selectOptions}
        onChange={handleOptionSelect}
        placeholder={placeholderText}
        isDisabled={false} {/* bool toggles affect entire plugin */}
        blurInputOnSelect={true} {/* don't want any input/keyboard on mobile */}
        readonly={true} {/* tried, didn't work */}
        searchable={false} {/* disables keyboard, but still shows iOS footer with "Done" button in Safari and Firefox, and an "X" in Chrome, and zooms in when touching select element */}
    />
like image 628
curtybear Avatar asked Mar 18 '19 19:03

curtybear


2 Answers

Try inputProps={{readOnly:true}} or isSearchable={ false }. readonly is not exposed as a direct prop on the <Select /> component.

like image 150
P Ackerman Avatar answered Oct 22 '22 23:10

P Ackerman


Craig, have you tried setting the font-size of the input to 16px? This prevents zooming on iOS when focusing an input field

like image 25
David McNeill Avatar answered Oct 23 '22 00:10

David McNeill