From e8f019a75f549d0611e7498a485d1012014a4974 Mon Sep 17 00:00:00 2001 From: JF-Cozy Date: Wed, 9 Oct 2024 16:55:06 +0200 Subject: [PATCH] feat(Assistant): Replace `enter` search default behavior only on desktop --- src/assistant/Conversations/ConversationSearchBar.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/assistant/Conversations/ConversationSearchBar.jsx b/src/assistant/Conversations/ConversationSearchBar.jsx index d9d5778c4d..b81b04a07e 100644 --- a/src/assistant/Conversations/ConversationSearchBar.jsx +++ b/src/assistant/Conversations/ConversationSearchBar.jsx @@ -9,6 +9,7 @@ import ArrowUpIcon from 'cozy-ui/transpiled/react/Icons/ArrowUp' import StopIcon from 'cozy-ui/transpiled/react/Icons/Stop' import ButtonBase from 'cozy-ui/transpiled/react/ButtonBase' import useEventListener from 'cozy-ui/transpiled/react/hooks/useEventListener' +import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints' import ResultMenu from '../ResultMenu/ResultMenu' import { useAssistant } from '../AssistantProvider' @@ -25,6 +26,7 @@ const ConversationSearchBar = ({ onClose }) => { const { t } = useI18n() + const { isMobile } = useBreakpoints() const { assistantState, onAssistantExecute } = useAssistant() const { setSearchValue, delayedSetSearchValue } = useSearch() const [inputValue, setInputValue] = useState('') @@ -120,7 +122,7 @@ const ConversationSearchBar = ({ ), onKeyDown: ev => { - if (ev.key === 'Enter') { + if (!isMobile && ev.key === 'Enter') { ev.preventDefault() // prevent form submit handleClick() }