fix: align Dropdown/Menu with the HeroUI baseline after fidelity audit

- menu-item.css keys disabled styling off the presence attribute Reka emits.
- Dropdown surfaces drive the ported enter/exit animations and use data-side
  for placement-specific motion.
- One role=menu per popup; items render their key as DOM id; submenu surfaces
  point aria-labelledby at the real trigger; MenuSection names its group from a
  nested Header.
- Custom (asChild) triggers stay keyboard focusable; library Button/Avatar keep
  their own layout instead of the custom-trigger rules.
- Items emit data-focused/data-hovered/data-pressed, expose the upstream render
  props to slots, and merge caller classes through tailwind-variants.
- Submenu triggers declare hasSubmenu explicitly and forward class/ARIA; the
  default submenu indicator uses the baseline chevron artwork.
- Demos restore Kbd slot="keyboard" (27x), IconSquarePlus, and remove the added
  comment, stray space and duplicated indicator SVGs.
- Document the page after the official structure and API tables, including
  renamed props, Vue extensions and remaining gaps.
This commit is contained in:
maoyingjie
2026-10-24 22:14:10 +08:00
parent 64aaf5e53f
commit 043a5418f3
27 changed files with 1124 additions and 254 deletions
@@ -15,6 +15,7 @@ import { menuSectionVariants } from "@heroui-vue/styles";
import {
menuContextKey,
menuSectionContextKey,
menuSectionLabelKey,
type MenuKey,
type MenuSelectionMode,
} from "../menu/context";
@@ -24,7 +25,6 @@ export default defineComponent({
name: "MenuSection",
inheritAttrs: false,
props: {
as: { type: String, default: "div" },
/** Section-level selection mode. Omit to inherit the menu's selection. */
selectionMode: {
type: String as PropType<MenuSelectionMode>,
@@ -60,11 +60,9 @@ export default defineComponent({
const acceptedKeys = computed(() =>
isControlled.value ? (props.selectedKeys ?? []) : internal.value,
);
const effectiveMode = computed<MenuSelectionMode>(() => {
if (props.selectionMode) return props.selectionMode;
if (ownsSelection.value) return "multiple";
return menuCtx?.selectionMode.value ?? "none";
});
const effectiveMode = computed<MenuSelectionMode>(
() => props.selectionMode ?? menuCtx?.selectionMode.value ?? "none",
);
const sectionSelection = useMenuSelection({
selectionMode: effectiveMode,
@@ -84,6 +82,21 @@ export default defineComponent({
},
);
// A nested Header registers here so the group keeps an accessible name.
const labelIds = ref<string[]>([]);
provide(menuSectionLabelKey, {
labelledBy: computed(() =>
labelIds.value.length ? labelIds.value.join(" ") : undefined,
),
registerLabel(id: string) {
if (!labelIds.value.includes(id))
labelIds.value = [...labelIds.value, id];
return () => {
labelIds.value = labelIds.value.filter((item) => item !== id);
};
},
});
provide(menuSectionContextKey, {
selection: {
get selectionMode() {
@@ -116,17 +129,22 @@ export default defineComponent({
},
});
return () =>
h(
return () => {
const labelledBy =
(attrs["aria-labelledby"] as string | undefined) ??
(labelIds.value.length ? labelIds.value.join(" ") : undefined);
return h(
RekaMenuGroup as never,
{
...attrs,
class: [menuSectionVariants(), attrs.class],
class: menuSectionVariants({ class: attrs.class as never }),
"aria-labelledby": labelledBy,
"data-slot": "menu-section",
role: "group",
role: (attrs.role as string | undefined) ?? "group",
},
slots,
);
};
},
});
</script>