React-day-picker: DayPickerInput on mobile triggers focus, which brings the keyboard over the calendar

Created on 6 Dec 2017  Â·  5Comments  Â·  Source: gpbl/react-day-picker

keyboard-on-focus

Strange... I see this problem was previously reported on #100, but I do get this problem with "react-day-picker": "^7.0.5" (upgraded from 6.2.1 30 mins ago).

Isn't anyone else getting this problem? The implementation is done through a DayPickerInput component.

Most helpful comment

For reference, I'd just like to point out that passing the property readOnly: true through inputProps made the input get the readonly attribute that prevents direct user input on the input field.

This is great because the keyboard will no longer be triggered on mobile, and therefore will not cover the calendar. This also improve input validation for those who must have it. ✨

<DayPickerInput
  inputProps={{ readOnly: true }}
  placeholder="DD/MM/YYYY"
  format="DD/MM/YYYY"
/>

Change the input style (like cursor: pointer) and you'll end up with an input that will be experienced more like a button.

Big thanks to @gpbl who guided me in the right direction.

All 5 comments

@dreamyguy the input component always worked like this on mobile. Could you show us the code that was working with v6? Maybe you were passing props to the input component that now should be passed via inputProps?

Sorry I could have been clearer. It was not working on v6 either, so I upgraded to see if it was working with v7. So no changes there.

I got the impression on #100 that this was not an issue with DayPickerInput, as another user suggested the screenshot taken was from another component/project.

So I guess there's no way around it, then?

For reference, I'd just like to point out that passing the property readOnly: true through inputProps made the input get the readonly attribute that prevents direct user input on the input field.

This is great because the keyboard will no longer be triggered on mobile, and therefore will not cover the calendar. This also improve input validation for those who must have it. ✨

<DayPickerInput
  inputProps={{ readOnly: true }}
  placeholder="DD/MM/YYYY"
  format="DD/MM/YYYY"
/>

Change the input style (like cursor: pointer) and you'll end up with an input that will be experienced more like a button.

Big thanks to @gpbl who guided me in the right direction.

Thanks for writing back @dreamyguy !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wenzoto picture wenzoto  Â·  6Comments

matfork-belatrix picture matfork-belatrix  Â·  5Comments

laidinidis picture laidinidis  Â·  6Comments

NikitaSasin picture NikitaSasin  Â·  5Comments

trevordmiller picture trevordmiller  Â·  4Comments