mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 16:58:47 +01:00
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 (
|
||||
<div
|
||||
ref={(node) => {
|
||||
|
@ -883,7 +899,7 @@ function Catchup() {
|
|||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<main onKeyDown={handleArrowKeys}>
|
||||
{uiState === 'start' && (
|
||||
<div class="catchup-start">
|
||||
<h1>
|
||||
|
|
Loading…
Reference in a new issue