Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad411b2

Browse files
committed
🆕 allow some input behaviours
On branch fix/remove-prevent-some-keys Changes to be committed: modified: src/set-mask.ts
1 parent 1be787d commit ad411b2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎src/set-mask.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,16 @@ function setMask(
223223
let start = element.selectionStart ?? lastPositionToNumber;
224224
let end = element.selectionEnd ?? lastPositionToNumber;
225225

226-
// Trigger input submit
227-
if (e.key === 'Enter') return;
226+
// Allow some input behaviours like submit, focus etc...
227+
if (['Enter', 'Tab', 'Shift'].includes(e.key)) return;
228228

229229
// Select all
230230
if (e.ctrlKey && e.key === 'a') return setCaretPosition([firstPositionToNumber, lastPositionToNumber]);
231231

232232
// Undo to first value
233233
if (e.ctrlKey && e.key === 'z') return triggerInputChanges(initialValue);
234234

235-
// Allow move caret after or before the prefix or suffix
235+
// Allow move caret between the prefix and suffix
236236
if (cursor === 'move' && (
237237
(e.key === 'ArrowLeft' && start > firstPositionToNumber) ||
238238
(e.key === 'ArrowRight' && start < lastPositionToNumber)

0 commit comments

Comments
 (0)