Files
heroui-vue/apps/docs/demos/dropdown-long-press-trigger.vue
T
maoyingjie 1692c6b0ac fix: menu selection ARIA, cancelable activation, submenu and long-press
- Selected items use menuitemradio/menuitemcheckbox + aria-checked + data-selected
- onClick preventDefault cancels action/selection/close (user handlers first)
- Submenu trigger is a single menuitem (asChild); standalone Menu owns Reka root
- DropdownRoot trigger=longPress with threshold, keyboard fallback, cleanup
- Export *Props types; independent tarball ESM/CSS + NodeNext/bundler contracts
- Esc still closes the full submenu stack (recorded gap)
2026-10-24 21:19:04 +08:00

37 lines
1.0 KiB
Vue

<script setup lang="ts">
import {
DropdownRoot,
DropdownTrigger,
DropdownPopover,
DropdownMenu,
DropdownItem,
Button,
Label,
} from "@heroui-vue/components";
</script>
<template>
<!-- trigger="longPress": press-and-hold opens; click is suppressed. -->
<DropdownRoot trigger="longPress">
<DropdownTrigger>
<Button aria-label="菜单" variant="secondary">长按</Button>
</DropdownTrigger>
<DropdownPopover>
<DropdownMenu>
<DropdownItem id="new-file" text-value="新建文件">
<Label>新建文件</Label>
</DropdownItem>
<DropdownItem id="open-file" text-value="打开文件">
<Label>打开文件</Label>
</DropdownItem>
<DropdownItem id="save-file" text-value="保存文件">
<Label>保存文件</Label>
</DropdownItem>
<DropdownItem id="delete-file" text-value="删除文件" variant="danger">
<Label>删除文件</Label>
</DropdownItem>
</DropdownMenu>
</DropdownPopover>
</DropdownRoot>
</template>