Skip to content

Commit a40ff70

Browse files
committed
fix(cursor): do not try to change cursor on non supported input types
1 parent e92b49f commit a40ff70

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/core.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ export function inputHandler(event) {
6464
export function updateCursor(el, cursorPosition, isCursorAtEnd, digit) {
6565
const display = el.value
6666

67+
// setSelectionRange applies only to inputs of types text, search, URL, tel and password.
68+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
69+
if (!['text', 'tel', 'search'].includes(el.getAttribute('type'))) {
70+
return
71+
}
72+
6773
// set the cursor position to an appropriate location
6874
if (el === document.activeElement) {
6975
if (isCursorAtEnd) {

0 commit comments

Comments
 (0)