Skip to content

Commit 7de81ee

Browse files
committed
fix(input-otp): ignore all meta shortcuts on keydown
1 parent e31c3ad commit 7de81ee

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/src/components/input-otp/input-otp.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,14 @@ export class InputOTP implements ComponentInterface {
544544
const rtl = isRTL(this.el);
545545
const input = event.target as HTMLInputElement;
546546

547-
const isPasteShortcut = (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'v';
547+
// Meta shortcuts are used to copy, paste, and select text
548+
// We don't want to handle these keys here
549+
const metaShortcuts = ['a', 'c', 'v', 'x', 'r', 'z', 'y'];
548550
const isTextSelection = input.selectionStart !== input.selectionEnd;
549551

550-
// Return if the key is the paste shortcut or the input value
552+
// Return if the key is a meta shortcut or the input value
551553
// text is selected and let the onPaste / onInput handler manage it
552-
if (isPasteShortcut || isTextSelection) {
554+
if (isTextSelection || ((event.metaKey || event.ctrlKey) && metaShortcuts.includes(event.key.toLowerCase()))) {
553555
return;
554556
}
555557

0 commit comments

Comments
 (0)