From 70a65e2c342a6c08bf0667734507820a84f5f835 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Wed, 9 Apr 2025 15:25:46 +0530 Subject: [PATCH] fix: Prevent mentions menu from triggering on reply mode change (#11264) # Pull Request Template ## Description **Issue:** When typing "@" in reply mode and then switching to private note mode, the user mentions menu remains visible and cannot be dismissed. **Cause:** The Prose Mirror suggestion plugin for "@" was active in both reply modes (normal and private). When triggered in normal reply mode and then switching to private note mode, the menu would remain open and couldn't be dismissed. **Solution** ``` createSuggestionPlugin({ trigger: '@', showMenu: showUserMentions, searchTerm: mentionSearchKey, isAllowed: () => props.isPrivate, // Only allow @ mentions in private note mode }), ``` 1. By setting `isAllowed: () => props.isPrivate`, the @ mention trigger will only activate when in private note mode 2. In normal reply mode, the plugin won't activate at all since `isAllowed` returns false 3. This prevents the menu from being triggered in the wrong context and fix the scenario where the menu gets stuck. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Loom video **Before** https://www.loom.com/share/5333f0c6498d4a9ea4d220b1de1b608c?sid=1425f24f-2c6f-4ff5-aab3-23c3203d2e05 **After** https://www.loom.com/share/9f183c76d6a94b618a7c2aaed280b780?sid=19ef08b8-2b70-434b-ad5a-267410212e11 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- .../dashboard/components/widgets/WootWriter/Editor.vue | 1 + .../dashboard/components/widgets/conversation/TagAgents.vue | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue b/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue index d9a0341b4..628c88ad3 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue @@ -220,6 +220,7 @@ const plugins = computed(() => { trigger: '@', showMenu: showUserMentions, searchTerm: mentionSearchKey, + isAllowed: () => props.isPrivate, }), createSuggestionPlugin({ trigger: '/', diff --git a/app/javascript/dashboard/components/widgets/conversation/TagAgents.vue b/app/javascript/dashboard/components/widgets/conversation/TagAgents.vue index 793275e3d..2e055cae6 100644 --- a/app/javascript/dashboard/components/widgets/conversation/TagAgents.vue +++ b/app/javascript/dashboard/components/widgets/conversation/TagAgents.vue @@ -69,10 +69,6 @@ const onAgentSelect = index => { v-if="items.length" ref="tagAgentsRef" class="vertical dropdown menu mention--box bg-n-solid-1 p-1 rounded-xl text-sm overflow-auto absolute w-full z-20 shadow-md left-0 leading-[1.2] bottom-full max-h-[12.5rem] border border-solid border-n-strong" - :class="{ - 'border-b-[0.5rem] border-solid border-white dark:!border-slate-700': - items.length <= 4, - }" >