From 371146cdfec0ebfb9b075444bf6b304030a61141 Mon Sep 17 00:00:00 2001 From: Keegan George Date: Wed, 26 Mar 2025 11:28:57 -0700 Subject: [PATCH] FIX: Post helper menu results should be selectable (#1221) This update fixes an issue where the results of the post helper menu was not selectable. Previously, selecting any text inside the menu was immediately closing the menu. --- .../components/ai-post-helper-menu.gjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/assets/javascripts/discourse/components/ai-post-helper-menu.gjs b/assets/javascripts/discourse/components/ai-post-helper-menu.gjs index 701d9368..ce013a1b 100644 --- a/assets/javascripts/discourse/components/ai-post-helper-menu.gjs +++ b/assets/javascripts/discourse/components/ai-post-helper-menu.gjs @@ -13,6 +13,7 @@ import FastEditModal from "discourse/components/modal/fast-edit"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; import { bind } from "discourse/lib/decorators"; +import { withPluginApi } from "discourse/lib/plugin-api"; import { sanitize } from "discourse/lib/text"; import { clipboardCopy } from "discourse/lib/utilities"; import { i18n } from "discourse-i18n"; @@ -69,6 +70,23 @@ export default class AiPostHelperMenu extends Component { @tracked _activeAiRequest = null; + constructor() { + super(...arguments); + + withPluginApi((api) => { + api.registerValueTransformer( + "post-text-selection-prevent-close", + ({ value }) => { + if (this.menuState === this.MENU_STATES.result) { + return true; + } + + return value; + } + ); + }); + } + get footnoteDisabled() { return this.streaming || !this.supportsAddFootnote; }