Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- `Card`, `CollapsibleCard`: update padding to match legacy `Card` component ([#76368](https://github.com/WordPress/gutenberg/pull/76368)).
- `CollapsibleCard`: move trigger to the header ([#76265](https://github.com/WordPress/gutenberg/pull/76265)).
- `CollapsibleCard`: add animations ([#76378](https://github.com/WordPress/gutenberg/pull/76378)).
- `CollapsibleCard`: allows the browser page search to find and expand the panel contents via the `hiddenUntilFound` prop. ([#76498](https://github.com/WordPress/gutenberg/pull/76498)).

## 0.8.0 (2026-03-04)

Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/collapsible-card/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import type { ContentProps } from './types';
*/
export const Content = forwardRef< HTMLDivElement, ContentProps >(
function CollapsibleCardContent(
{ className, render, children, ...restProps },
{ className, render, children, hiddenUntilFound = true, ...restProps },
ref
) {
return (
<Collapsible.Panel
ref={ ref }
className={ clsx( styles.content, className ) }
hiddenUntilFound={ hiddenUntilFound }
{ ...restProps }
>
<Card.Content
Expand Down
12 changes: 3 additions & 9 deletions packages/ui/src/collapsible-card/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ describe( 'CollapsibleCard', () => {
</CollapsibleCard.Root>
);

expect(
screen.queryByText( 'Hidden content' )
).not.toBeInTheDocument();
expect( screen.getByText( 'Hidden content' ) ).not.toBeVisible();
} );

it( 'shows content when defaultOpen is true', () => {
Expand Down Expand Up @@ -87,9 +85,7 @@ describe( 'CollapsibleCard', () => {
</CollapsibleCard.Root>
);

expect(
screen.queryByText( 'Toggle content' )
).not.toBeInTheDocument();
expect( screen.getByText( 'Toggle content' ) ).not.toBeVisible();

await user.click(
screen.getByRole( 'button', {
Expand All @@ -107,9 +103,7 @@ describe( 'CollapsibleCard', () => {
} )
);

expect(
screen.queryByText( 'Toggle content' )
).not.toBeInTheDocument();
expect( screen.getByText( 'Toggle content' ) ).not.toBeVisible();
} );

it( 'calls onOpenChange when toggled', async () => {
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/src/collapsible-card/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ReactNode } from 'react';
import type { PanelProps } from '../collapsible/types';
import type { ComponentProps } from '../utils/types';

export interface RootProps extends ComponentProps< 'div' > {
Expand Down Expand Up @@ -41,4 +42,13 @@ export interface ContentProps extends ComponentProps< 'div' > {
* The content to be rendered inside the collapsible content area.
*/
children?: ReactNode;
/**
* Allows the browser’s built-in page search to find and expand the panel contents.
*
* Overrides the `keepMounted` prop and uses `hidden="until-found"`
* to hide the element without removing it from the DOM.
*
* @default true
*/
hiddenUntilFound?: PanelProps[ 'hiddenUntilFound' ];
}
Loading