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:
@@ -1,6 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, h, useAttrs } from "vue";
|
||||
import {
|
||||
defineComponent,
|
||||
h,
|
||||
inject,
|
||||
onUnmounted,
|
||||
useAttrs,
|
||||
useId,
|
||||
watch,
|
||||
} from "vue";
|
||||
import { headerVariants } from "@heroui-vue/styles";
|
||||
import { menuSectionLabelKey } from "../menu/context";
|
||||
|
||||
/**
|
||||
* Collection / group section heading (RAC Header).
|
||||
@@ -19,12 +28,33 @@ export default defineComponent({
|
||||
},
|
||||
setup(props, { slots }) {
|
||||
const attrs = useAttrs();
|
||||
// Inside a MenuSection the header names the group (upstream wires this
|
||||
// through the collection); elsewhere it stays a plain heading element.
|
||||
const section = inject(menuSectionLabelKey, null);
|
||||
const autoId = useId();
|
||||
let unregister: (() => void) | undefined;
|
||||
const resolveId = () =>
|
||||
(attrs.id as string | undefined) || (section ? autoId : undefined);
|
||||
watch(
|
||||
resolveId,
|
||||
(id, prev) => {
|
||||
if (!section || !id || id === prev) return;
|
||||
unregister?.();
|
||||
unregister = section.registerLabel(id);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
onUnmounted(() => {
|
||||
unregister?.();
|
||||
unregister = undefined;
|
||||
});
|
||||
|
||||
function render() {
|
||||
return h(
|
||||
props.as,
|
||||
{
|
||||
...attrs,
|
||||
id: resolveId(),
|
||||
class: [headerVariants(), attrs.class],
|
||||
"data-slot": "header",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user