From fdf552a9ec95ba409d35d933c1eb504b968cdef5 Mon Sep 17 00:00:00 2001 From: leon-up9 <97597983+leon-up9@users.noreply.github.com> Date: Mon, 31 Jan 2022 17:08:03 +0200 Subject: [PATCH] TRA-4169 apply query by enter (#733) --- ui/src/hooks/useKeyPress.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/src/hooks/useKeyPress.ts b/ui/src/hooks/useKeyPress.ts index 4f14fd2c7..caf864eb3 100644 --- a/ui/src/hooks/useKeyPress.ts +++ b/ui/src/hooks/useKeyPress.ts @@ -10,8 +10,11 @@ const useKeyPress = (eventConfigs, callback, node = null) => { // handle what happens on key press const handleKeyPress = useCallback( (event) => { + // check if one of the key is part of the ones we want if (eventConfigs.some((eventConfig) => Object.keys(eventConfig).every(nameKey => eventConfig[nameKey] === event[nameKey]))) { + event.stopPropagation() + event.preventDefault(); callbackRef.current(event); } },