This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Commit 6c224a2
committed
fix(ngAria): do not scroll when pressing spacebar on custom buttons
By default, pressing spacebar causes the browser to scroll down.
However, when a native button is focused, the button is clicked instead.
`ngAria`'s `ngClick` directive, sets elements up to behave like buttons.
For example, it adds `role="button"` and forwards `ENTER` and `SPACEBAR`
keypresses to the `click` handler (to emulate the behavior of native
buttons).
Yet, pressing spacebar on such an element, still invokes the default
browser behavior of scrolling down.
This commit fixes this, by calling `preventDefault()` on the keyboard
event, thus preventing the default scrolling behavior and making custom
buttons behave closer to native ones.
Closes #14665
Closes #166041 parent af1e6a3 commit 6c224a2
2 files changed
+9
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
391 | 394 | | |
392 | 395 | | |
393 | 396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
929 | 929 | | |
930 | 930 | | |
931 | 931 | | |
932 | | - | |
| 932 | + | |
| 933 | + | |
933 | 934 | | |
934 | 935 | | |
935 | 936 | | |
936 | | - | |
| 937 | + | |
937 | 938 | | |
938 | 939 | | |
939 | 940 | | |
| |||
948 | 949 | | |
949 | 950 | | |
950 | 951 | | |
951 | | - | |
| 952 | + | |
952 | 953 | | |
953 | 954 | | |
954 | 955 | | |
| |||
967 | 968 | | |
968 | 969 | | |
969 | 970 | | |
970 | | - | |
| 971 | + | |
971 | 972 | | |
972 | 973 | | |
973 | 974 | | |
| |||
0 commit comments