mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 14:14:17 +08:00
fix(web): type select change
This commit is contained in:
parent
7c348e994c
commit
1a0776ce9b
@ -149,6 +149,30 @@ describe('ShortcutsPopupPlugin', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('does not close on mousedown inside a Base UI portal overlay', async () => {
|
||||
render(<MinimalEditor />)
|
||||
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(<MinimalEditor withContainer />)
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user