Skip to content

Commit

Permalink
[Collapsible] Update props destructuring to fix Trigger disabled state (
Browse files Browse the repository at this point in the history
mui#1469)

Co-authored-by: Albert Yu <[email protected]>
  • Loading branch information
2 people authored and atomiks committed Feb 28, 2025
1 parent 38cef89 commit 2cefe46
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions packages/react/src/collapsible/root/CollapsibleRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ describe('<Collapsible.Root />', () => {
});
});

describe('collapsible status', () => {
it('disabled status', async () => {
const { getByRole } = await render(
<Collapsible.Root disabled>
<Collapsible.Trigger />
<Collapsible.Panel data-testid="panel" />
</Collapsible.Root>,
);

const trigger = getByRole('button');

expect(trigger).to.have.attribute('data-disabled');
});
});

describe('open state', () => {
it('controlled mode', async () => {
const { queryByText, getByRole, setProps } = await render(
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/collapsible/trigger/CollapsibleTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const CollapsibleTrigger = React.forwardRef(function CollapsibleTrigger(
props: CollapsibleTrigger.Props,
forwardedRef: React.ForwardedRef<HTMLButtonElement>,
) {
const { className, disabled = false, id, render, ...otherProps } = props;
const { panelId, open, setOpen, state, disabled: contextDisabled } = useCollapsibleRootContext();

const { panelId, open, setOpen, state } = useCollapsibleRootContext();
const { className, disabled = contextDisabled, id, render, ...otherProps } = props;

const { getRootProps } = useCollapsibleTrigger({
disabled,
Expand Down

0 comments on commit 2cefe46

Please sign in to comment.