Fix radio inputs intercept arrow keys
This commit is contained in:
parent
41af07c440
commit
f3895d09e3
1 changed files with 17 additions and 1 deletions
|
@ -822,6 +822,22 @@ function Catchup() {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleArrowKeys = useCallback((e) => {
|
||||||
|
const activeElement = document.activeElement;
|
||||||
|
const isRadio =
|
||||||
|
activeElement?.tagName === 'INPUT' && activeElement.type === 'radio';
|
||||||
|
const isArrowKeys =
|
||||||
|
e.key === 'ArrowDown' ||
|
||||||
|
e.key === 'ArrowUp' ||
|
||||||
|
e.key === 'ArrowLeft' ||
|
||||||
|
e.key === 'ArrowRight';
|
||||||
|
if (isArrowKeys && isRadio) {
|
||||||
|
// Note: page scroll won't trigger on first arrow key press due to this. Subsequent presses will.
|
||||||
|
activeElement.blur();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={(node) => {
|
ref={(node) => {
|
||||||
|
@ -883,7 +899,7 @@ function Catchup() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main onKeyDown={handleArrowKeys}>
|
||||||
{uiState === 'start' && (
|
{uiState === 'start' && (
|
||||||
<div class="catchup-start">
|
<div class="catchup-start">
|
||||||
<h1>
|
<h1>
|
||||||
|
|
Loading…
Add table
Reference in a new issue