Repository navigation
Commit 432b2aa
committed
fix: prevent console error when using datalist with text inputs
Fix two issues that cause errors when native HTML datalist elements are
used with USWDS text inputs:
1. keymap.js: Guard against non-KeyboardEvent events. When a user
selects a datalist option, the browser fires an InputEvent (not a
KeyboardEvent). The keymap handler called getModifierState() and
accessed event.key on the InputEvent, causing a TypeError. Add an
early return when the event lacks these KeyboardEvent properties.
2. validate-input.js: Move the null check for validatorCheckbox before
its first use. Previously, classList.toggle() was called on line 30
before the existence check on line 32, causing a TypeError when the
validator checkbox element was not found in the DOM.
Fixes #6567
Signed-off-by: Vijay Govindarajan <vijay.govindarajan91@gmail.com>
Signed-off-by: V Govindarajan <vijay.govindarajan91@gmail.com>1 parent 0a801d7 commit 432b2aa
2 files changed
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
21 | 30 | | |
22 | 31 | | |
23 | 32 | | |
| |||
39 | 48 | | |
40 | 49 | | |
41 | 50 | | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
35 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
0 commit comments