From dadd572f9d5fdf47162c8b04c141adfac256dd30 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 22 Aug 2024 16:40:55 +0530 Subject: [PATCH] refactor: `useKeyboardEvents` composable (#9959) This PR has the following changes 1. Fix tab styles issue caused by adding an additional wrapper for getting an element ref on `ChatTypeTabs.vue` 2. Refactor `useKeyboardEvents` composable to not require an element ref. It will use a local abort controller to abort any listener --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> --- .../dashboard/components/ChatList.vue | 2 +- .../components/buttons/ResolveAction.vue | 8 +-- .../dashboard/components/layout/Sidebar.vue | 7 +-- .../components/widgets/AIAssistanceButton.vue | 6 +-- .../components/widgets/ChatTypeTabs.vue | 33 ++++++------ .../components/widgets/LabelSelector.vue | 10 +--- .../widgets/WootWriter/ReplyBottomPanel.vue | 17 ++---- .../widgets/WootWriter/ReplyTopPanel.vue | 11 +--- .../conversation/ConversationHeader.vue | 10 +--- .../widgets/conversation/MessagesView.vue | 5 +- .../widgets/conversation/TagAgents.vue | 1 - .../conversation/components/GalleryView.vue | 4 +- .../widgets/mentions/MentionBox.vue | 1 - .../spec/useKeyboardEvents.spec.js | 5 +- .../spec/useKeyboardNavigableList.spec.js | 22 +------- .../composables/useKeyboardEvents.js | 53 +++++-------------- .../composables/useKeyboardNavigableList.js | 3 +- .../modules/notes/components/AddNote.vue | 4 +- .../conversation/labels/LabelBox.vue | 6 +-- .../components/ArticleSearch/Header.vue | 5 +- .../portal/components/SearchSuggestions.vue | 1 - .../components/ui/dropdown/DropdownMenu.vue | 2 +- 22 files changed, 56 insertions(+), 160 deletions(-) diff --git a/app/javascript/dashboard/components/ChatList.vue b/app/javascript/dashboard/components/ChatList.vue index fa95c5024..476fc7438 100644 --- a/app/javascript/dashboard/components/ChatList.vue +++ b/app/javascript/dashboard/components/ChatList.vue @@ -141,7 +141,7 @@ export default { allowOnFocusedInput: true, }, }; - useKeyboardEvents(keyboardEvents, conversationListRef); + useKeyboardEvents(keyboardEvents); return { uiSettings, diff --git a/app/javascript/dashboard/components/buttons/ResolveAction.vue b/app/javascript/dashboard/components/buttons/ResolveAction.vue index 7c4c4daaa..0626ced59 100644 --- a/app/javascript/dashboard/components/buttons/ResolveAction.vue +++ b/app/javascript/dashboard/components/buttons/ResolveAction.vue @@ -19,7 +19,6 @@ const store = useStore(); const getters = useStoreGetters(); const { t } = useI18n(); -const resolveActionsRef = ref(null); const arrowDownButtonRef = ref(null); const isLoading = ref(false); @@ -131,17 +130,14 @@ const keyboardEvents = { }, }; -useKeyboardEvents(keyboardEvents, resolveActionsRef); +useKeyboardEvents(keyboardEvents); useEmitter(CMD_REOPEN_CONVERSATION, onCmdOpenConversation); useEmitter(CMD_RESOLVE_CONVERSATION, onCmdResolveConversation);