diff --git a/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/__tests__/index.spec.tsx b/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/__tests__/index.spec.tsx
index e3fba27cf2..c282706706 100644
--- a/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/__tests__/index.spec.tsx
+++ b/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/__tests__/index.spec.tsx
@@ -149,6 +149,30 @@ describe('ShortcutsPopupPlugin', () => {
})
})
+ it('does not close on mousedown inside a Base UI portal overlay', async () => {
+ render()
+ const ce = screen.getByTestId(CONTENT_EDITABLE_ID)
+ ce.focus()
+
+ fireEvent.keyDown(document, { key: '/', ctrlKey: true })
+ expect(await screen.findByText(SHORTCUTS_EMPTY_CONTENT)).toBeInTheDocument()
+
+ const portal = document.createElement('div')
+ portal.setAttribute('data-base-ui-portal', '')
+ const portalChild = document.createElement('button')
+ portalChild.textContent = 'portal-child'
+ portal.appendChild(portalChild)
+ document.body.appendChild(portal)
+
+ fireEvent.mouseDown(portalChild)
+
+ await waitFor(() => {
+ expect(screen.getByText(SHORTCUTS_EMPTY_CONTENT)).toBeInTheDocument()
+ })
+
+ portal.remove()
+ })
+
// ─── Container / portal ───
it('portals into provided container when container is set', async () => {
render()
diff --git a/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.tsx b/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.tsx
index 56b34b96e3..e3bee154d8 100644
--- a/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.tsx
+++ b/web/app/components/base/prompt-editor/plugins/shortcuts-popup-plugin/index.tsx
@@ -273,6 +273,9 @@ export default function ShortcutsPopupPlugin({
/* v8 ignore next 2 -- outside-click listener can race with ref cleanup during close/unmount; null-ref path is a safety guard. @preserve */
if (!portalRef.current)
return
+ const target = e.target as HTMLElement | null
+ if (target?.closest('[data-base-ui-portal]'))
+ return
if (!portalRef.current.contains(e.target as Node))
closePortal()
}