Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

ios input focus bug #571

Open
yansm opened this issue Oct 19, 2018 · 2 comments
Open

ios input focus bug #571

yansm opened this issue Oct 19, 2018 · 2 comments

Comments

@yansm
Copy link

yansm commented Oct 19, 2018

FastClick.prototype.focus = function(targetElement) {
var length;
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') {
// must targetElement.focus() first
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
method setSelectionRange can set selection in a focused input element
and in this example (https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange),
function SelectText () {
var input = document.getElementById("mytextbox");
input.focus();
input.setSelectionRange(2,5);
}

also input.focus() first
so, if you want use setSelectionRange, you must input.focus() first

in my code, click input can not focus, must rewrite FastClick.prototype.focus.

is it a bug in ios?

@franciscobrba
Copy link

@ftlabs please, help with that

@AntiMoron
Copy link

Try this?

class="needsclick"

This works for me... I ran into same problem today.

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

No branches or pull requests

3 participants