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

Input disableTouchKeyboard #787

Closed
Glideh opened this issue Jan 17, 2014 · 13 comments · Fixed by #842
Closed

Input disableTouchKeyboard #787

Glideh opened this issue Jan 17, 2014 · 13 comments · Fixed by #842
Milestone

Comments

@Glideh
Copy link

Glideh commented Jan 17, 2014

In input mode, shouldn't we have a disableTouchKeyboard option to prevent mobile keyboard to pop out when the input is focused ?
Setting it readonly seems not a good idea for me as it suggests we can't change the value.

@CalamityJames
Copy link
Contributor

This would definitely be useful, as the touch keyboard on most devices obscures half the page, which when you're working with a datepicker anyway means that the form becomes rather unwieldy.

Screenshot: https://f.cloud.github.com/assets/5637797/2217996/cafd628a-9a25-11e3-8887-5e12fb459335.png

@eternicode eternicode added this to the 1.3.1 milestone Mar 2, 2014
@eternicode
Copy link
Contributor

I'm not sure this is possible, outside of setting readonly on the input. If you have any reading on doing this from a webpage, feel free to link it, but some searching on my part turned up a lot of "nope, can't do that". I seem to recall that some mobile browsers had proprietary css for disabling the keyboard, but I can't find anything about that now.

readonly just means the user can't change the value -- the page (via js) can always change the value (even for disabled inputs!). I agree it's not a great solution, but it looks like the only solution we have right now.

@Glideh
Copy link
Author

Glideh commented Mar 3, 2014

I use it with jonthornton/jquery-timepicker (look at the related option).
I didn't check the implementation though.

@Glideh
Copy link
Author

Glideh commented Mar 3, 2014

Also (I didn't see this option) maybe we should have an HTML5 date input fallback for browsers supporting it, but that's another issue

@CalamityJames
Copy link
Contributor

Thanks for the example @Glideh, I've managed to include that in the scripts (adds the option disableTouchKeyboard with a default of false) and it seems to be working!

https://f.cloud.github.com/assets/5637797/2308633/86b99b94-a2c1-11e3-9739-2e3a7c8b8719.png

@Glideh
Copy link
Author

Glideh commented Mar 3, 2014

Good catch, thanks for the PR.

(window.navigator.msMaxTouchPoints || 'ontouchstart' in document)

Seems indeed to be the key

@acrobat acrobat modified the milestones: 1.3.2, 1.4.0 Dec 15, 2014
@acrobat acrobat mentioned this issue Dec 26, 2014
6 tasks
@MrSleeps
Copy link

I'm still having an issue with this, it still pops up the keyboard on both the Samsung s4 mini and Sony Xperia Z3 (android 4.4.2 and 4.4.4 respectively). Pulling my hair out on this one..

@CalamityJames
Copy link
Contributor

Confirmed re-occurring on my Galaxy S6 Edge too running Android 5.0.2 on Chrome and stock browser.

I don't have an iPhone to test on though I'm afraid.

Sorry chaps. Will try and find some time to dig back through the code and see what's different in newer rendering engines (maybe the msMaxTouchPoints or ontouchstart variables are not passed any more).

@razvanphp
Copy link

Can you try this? I don't have access to Android devices, but this code snippet is from a rather great library, interact.js, so it should be actual.

var supportsTouch = (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch);

@acrobat
Copy link
Member

acrobat commented Jun 23, 2015

@razvanphp can you create a jsfiddle to test the piece of code? I have access to a fex android and ios devices so i'm able to test the snippet on different types of devices!

@maximelebreton
Copy link

+1

v1.5.0
HTC One with Android 5.0.2
Chrome 47.0

@maximelebreton
Copy link

i dont think that msMaxTouchPoints or ontouchstart variables are the problem, because i made this workaround based on the same variables and it works.

i've just added a little trick to improve accessibility. (but of course this is not perfect)

var isDatepickerVisible = false;

$('.datepicker').datepicker({
    disableTouchKeyboard: false

  }).on('show', function(e) {
    /**
     * hack to disable touch keyboard with blur() method,
     * but only if the datepicker is not visible (to minimize accessibility problems)
     * so with a second click, the keyboard appears
     */
    if ((window.navigator.msMaxTouchPoints || 'ontouchstart' in document)) {
      if (!isDatepickerVisible) {
        $('input', $(this))[0].blur();
      }
    }
    isDatepickerVisible = true;

  }).on('hide', function(e) {
    isDatepickerVisible = false;
  });

tested on:
HTC One / Android 5.0.2 / Chrome 47.0
iPad 3 / iOS 9.0.2 / Chrome & Safari

@acrobat
Copy link
Member

acrobat commented Feb 8, 2016

@maximelebreton care to create a PR with a fix?

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

Successfully merging a pull request may close this issue.

7 participants