Skip to content

Commit

Permalink
Components: tab panel: don't render hidden content by default (#57046)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored and artemiomorales committed Jan 4, 2024
1 parent 094e668 commit 8a22d90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Experimental

- `TabPanel`: do not render hidden content ([#57046](https://github.com/WordPress/gutenberg/pull/57046)).

## 25.14.0 (2023-12-13)

### Enhancements
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/tabs/tabpanel.tsx
Expand Up @@ -32,6 +32,7 @@ export const TabPanel = forwardRef<
}
const { store, instanceId } = context;
const instancedTabId = `${ instanceId }-${ tabId }`;
const selectedId = store.useState( ( state ) => state.selectedId );

return (
<StyledTabPanel
Expand All @@ -41,7 +42,7 @@ export const TabPanel = forwardRef<
focusable={ focusable }
{ ...otherProps }
>
{ children }
{ selectedId === instancedTabId && children }
</StyledTabPanel>
);
} );
Expand Up @@ -120,7 +120,7 @@ describe( 'Editing modes (visual/HTML)', () => {
'//button[@role="tab"][contains(text(), "Block")]'
);
inactiveBlockInspectorTab.click();
const noBlocksElement = await page.$(
const noBlocksElement = page.waitForSelector(
'.block-editor-block-inspector__no-blocks'
);
expect( noBlocksElement ).not.toBeNull();
Expand Down

0 comments on commit 8a22d90

Please sign in to comment.