From 81cb52d174b8226bd9e115eee24c960bd732b820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Mon, 14 Aug 2023 11:13:54 +0200 Subject: [PATCH] Fix naviguation with up key --- .../components/conversation/select/SelectCommune.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/site/source/components/conversation/select/SelectCommune.tsx b/site/source/components/conversation/select/SelectCommune.tsx index 8c3e27a17..0b023c1e4 100644 --- a/site/source/components/conversation/select/SelectCommune.tsx +++ b/site/source/components/conversation/select/SelectCommune.tsx @@ -109,7 +109,13 @@ export default function Select({ return } setFocusedElem( - (focusedElem + (e.key === 'ArrowDown' ? 1 : -1)) % + (focusedElem) => + (focusedElem + + (e.key === 'ArrowDown' + ? 1 + : focusedElem === 0 + ? searchResults.length - 1 + : -1)) % searchResults.length ) e.preventDefault() @@ -124,7 +130,7 @@ export default function Select({ break } }, - [searchResults, focusedElem, setSearchResults, submitFocusedElem, noResult] + [searchResults, setSearchResults, submitFocusedElem, noResult] ) return ( @@ -141,6 +147,7 @@ export default function Select({ label={t('Commune ou code postal')} value={name} onChange={handleChange} + autoComplete="off" /> {!!searchResults && (