Skip to content

[Bug] ToggleButtonGroup: className, style and other host props never reach the group element #8926

Closed

Description

@duytbp

Description

ToggleButtonGroup accepts no className or style, and passes nothing beyond data-testid and xstyle to its root. Its props interface (ToggleButtonGroup.tsx:77) does not extend BaseProps, and the role="group" root (ToggleButtonGroup.tsx:227) spreads no caller props. TypeScript rejects className and style; at runtime they are dropped, and so are id, aria-* and other data-* attributes.

BaseProps describes itself as the base "extended by all component prop interfaces", and ToggleButton itself took className in #6943. A team styling with CSS classes or a utility framework, or a wrapper that forwards host attributes, cannot reach the group without a wrapper element. This is the same gap #8755 closes for Overlay, DropdownMenuGroup and MobileNavToggle (architecture:public-component-api INV5).

Expected: the group extends BaseProps<HTMLDivElement> and spreads the remaining props onto its root, with its own role, aria-label and theme target applied after the spread.

Reproduction

import {ToggleButton, ToggleButtonGroup} from '@astryxdesign/core';

export function Repro() {
  return (
    <ToggleButtonGroup
      label="Alignment"
      type="single"
      value={null}
      onChange={() => {}}
      // @ts-expect-error not in the props type
      className="toolbar-group"
      style={{marginTop: 8}}>
      <ToggleButton label="Left" value="left" />
      <ToggleButton label="Right" value="right" />
    </ToggleButtonGroup>
  );
}
  1. Render the example and inspect the role="group" element.
  2. It has neither the toolbar-group class nor the inline style.

Astryx Version

@astryxdesign/core@0.7.4; still present on main (14fc587).

Environment

Any; reproduced in jsdom.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions