fix(dropdown): preserve grouped root attrs and events without breaking seams

This commit is contained in:
maoyingjie
2026-10-28 12:35:35 +08:00
parent 8b1505438e
commit f8de4529f6
12 changed files with 305 additions and 23 deletions
@@ -33,10 +33,9 @@ export default defineComponent({
/** Long-press duration in ms (longPress trigger). */
longPressDuration: { type: Number, default: LONG_PRESS_DURATION },
/**
* Absorbs ButtonGroup's direct-child marker; not a public API. When marked,
* the root wrapper is skipped so the trigger keeps the positional slot the
* group seam styles rely on — upstream `Dropdown` has no DOM root (RAC
* `MenuTrigger` renders a bare SlotProvider) and drops root-level attrs.
* Absorbs ButtonGroup's direct-child marker; not a public API. The wrapper
* remains the attrs/event host; group styles use its position to shape the
* nested trigger instead of dropping the root and its consumer attributes.
*/
__button_group_child: { type: Boolean, default: false },
},
@@ -78,10 +77,6 @@ export default defineComponent({
},
{ default: () => slots.default?.() },
);
// ButtonGroup member: no wrapper element, so the trigger button is the
// group's positional child and the shared seam rules apply unchanged.
if (props.__button_group_child) return menu;
return h(
"div",
{
@@ -89,6 +84,7 @@ export default defineComponent({
class: [slotsComputed.value.root(), attrs.class],
"data-slot": "dropdown-root",
"data-trigger": props.trigger,
"data-button-group-child": props.__button_group_child || undefined,
},
[menu],
);