InseeFr / Lunatic

Library of questionnaire components
https://inseefr.github.io/Lunatic/
MIT License
20 stars 21 forks source link

Suggester #960

Closed ddecrulle closed 5 months ago

ddecrulle commented 5 months ago

Describe the bug

Suggester is not working as expected since the arbitrary option has been added.

To Reproduce

With classic suggester

When we clear the suggester after selecting an option without losing focus and we write some text, searches are well executed but not displayed because onBlur has been called by onChange and the local isFocused state in useSuggestion is false so only selected option are displayed

https://github.com/InseeFr/Lunatic/assets/81740200/e630835d-a2cb-462d-9899-2145adffa738

with arbitrary option :

https://github.com/InseeFr/Lunatic/assets/81740200/f091ff24-43df-40ab-b2bf-3fa19ca3ae1c

https://github.com/InseeFr/Lunatic/assets/81740200/e420092d-3a02-4eee-b30f-929c0d67386e

Grafikart commented 5 months ago

Le coeur du problème résulte de cet évènement onBlur car dans un scénario classique :

Maintenant le souci c'est que souvent quand on clique sur une suggestion, on déclenche aussi le "blur" du champs ce qui déclenche le onBlur.