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

ios input focus bug #571

@yansm

Description

@yansm

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions