fix(dropdown): keep dropdown trigger positional inside ButtonGroup

Review of the restored button-group demos found the merged pull-request
group's seam broken: DropdownRoot renders a .hv-dropdown wrapper (a recorded
Vue adaptation) so the trigger button stopped being a positional child of
.button-group and matched :first-child:last-child, taking a full 24px radius
against the merge button's 24/0 end cap. The internal __button_group_child
marker also leaked onto the DOM.

Upstream Dropdown has no DOM root (RAC MenuTrigger renders a bare
SlotProvider and drops root props), so the trigger naturally occupies the
group's :last-child slot and the shared seam rules apply unchanged.

- DropdownRoot absorbs the ButtonGroup direct-child marker and skips the
  wrapper when marked, restoring positional seam radii and outline seam
  borders without touching the styles package (kept line-parity with the
  pinned source)
- wrapper contract (data-slot=dropdown-root, data-trigger, root class host)
  unchanged outside ButtonGroup; documented in dropdown.md
- regression tests: positional trigger + no marker leak in groups, wrapper
  still hosts root class standalone
This commit is contained in:
maoyingjie
2026-10-28 11:39:39 +08:00
parent dfd5248c9b
commit 123e3f9cba
3 changed files with 74 additions and 16 deletions
@@ -32,6 +32,13 @@ 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.
*/
__button_group_child: { type: Boolean, default: false },
},
emits: ["update:open"],
setup(props, { slots, emit }) {
@@ -59,8 +66,23 @@ export default defineComponent({
suppressOpenRequests,
});
return () =>
h(
return () => {
const menu = h(
RekaDropdownMenuRoot as never,
{
open: isOpen.value,
defaultOpen: props.defaultOpen,
dir: props.dir,
modal: props.modal,
"onUpdate:open": (value: boolean) => setOpen(value),
},
{ 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",
{
...attrs,
@@ -68,20 +90,9 @@ export default defineComponent({
"data-slot": "dropdown-root",
"data-trigger": props.trigger,
},
[
h(
RekaDropdownMenuRoot as never,
{
open: isOpen.value,
defaultOpen: props.defaultOpen,
dir: props.dir,
modal: props.modal,
"onUpdate:open": (value: boolean) => setOpen(value),
},
{ default: () => slots.default?.() },
),
],
[menu],
);
};
},
});
</script>