Skip to content

Commit 812ec04

Browse files
author
Lubov Raskina
committed
fix isBackspaceKey method for IOS with Chinese language
1 parent 84dfcbe commit 812ec04

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

angular-code-input/src/lib/code-input.component.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export class CodeInputComponent implements AfterViewInit, OnInit, OnChanges, OnD
386386
return Promise.resolve(true);
387387
}
388388

389-
// process only key with placeholder keycode on android devices
389+
// process only key with placeholder keycode on android devices or IOS with Chinese language
390390
if (!e.keyCode || e.keyCode !== 229) {
391391
return Promise.resolve(false);
392392
}
@@ -400,10 +400,14 @@ export class CodeInputComponent implements AfterViewInit, OnInit, OnChanges, OnD
400400
}
401401
// if backspace key pressed the caret will have position 0 (for single value field)
402402
resolve(input.selectionStart === 0 && !isReset);
403-
});
403+
}, this.isIOS() ? 100 : 0);
404404
});
405405
}
406406

407+
private isIOS():boolean {
408+
return /ipad|iphone|ipod/i.test(navigator.userAgent);
409+
}
410+
407411
private isDeleteKey(e: any): boolean {
408412
return (e.key && e.key.toLowerCase() === 'delete') || (e.keyCode && e.keyCode === 46);
409413
}

0 commit comments

Comments
 (0)