iter(g86): 弹层外部点击监听改按需挂载
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { effect, h, signal } from '@ui-arch/frame';
|
||||
import type { Signal } from '@ui-arch/frame';
|
||||
import { pushOverlay } from './overlay.js';
|
||||
import { bindOutside, pushOverlay } from './overlay.js';
|
||||
import { flip } from './position.js';
|
||||
import type { MultiSelectProps } from './types.js';
|
||||
|
||||
@@ -101,10 +101,7 @@ export function multiSelect(props: MultiSelectProps): HTMLElement {
|
||||
if (e.key === 'Escape') { open(false); return; }
|
||||
});
|
||||
|
||||
document.addEventListener('click', (e) => {
|
||||
if (root.contains(e.target as Node)) return; // 卫语句:组件内点击不处理
|
||||
open(false);
|
||||
});
|
||||
bindOutside(root, open, () => open(false)); // 点外部收起:仅展开期间挂监听,收起即摘
|
||||
effect(render);
|
||||
effect(() => {
|
||||
if (open()) releaseEsc ??= pushOverlay(() => { open(false); input.focus(); }); // 入栈逐层关闭
|
||||
|
||||
Reference in New Issue
Block a user