feat(navigation-menu): enhance context handling and lifecycle management
This commit is contained in:
@@ -45,9 +45,11 @@ function handleSelect(event: Event) {
|
||||
local.value = next;
|
||||
emit('update:checked', next);
|
||||
|
||||
const selectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true })
|
||||
;(event.currentTarget as HTMLElement).dispatchEvent(selectEvent);
|
||||
emit('select', event);
|
||||
const target = event.currentTarget as HTMLElement;
|
||||
const selectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
|
||||
// Emit the cancelable ITEM_SELECT event so `@select` preventDefault works.
|
||||
target.addEventListener(ITEM_SELECT, e => emit('select', e), { once: true });
|
||||
target.dispatchEvent(selectEvent);
|
||||
if (!selectEvent.defaultPrevented) rootCtx.onClose();
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user