Skip to content

Commit

Permalink
Components: refactor TabPanel to pass exhaustive-deps (#44935)
Browse files Browse the repository at this point in the history
Co-authored-by: Lena Morita <lena@jaguchi.com>
  • Loading branch information
chad1008 and mirka committed Oct 25, 2022
1 parent 7200d0c commit c97cf39
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- `SlotFill`: updated to satisfy `react/exhaustive-deps` eslint rule ([#44403](https://github.com/WordPress/gutenberg/pull/44403))
- `Context`: updated to ignore `react/exhaustive-deps` eslint rule ([#45044](https://github.com/WordPress/gutenberg/pull/45044))
- `Button`: Refactor Storybook to controls and align docs ([#44105](https://github.com/WordPress/gutenberg/pull/44105)).
- `TabPanel`: updated to satisfy `react/exhaustive-deps` eslint rule ([#44935](https://github.com/WordPress/gutenberg/pull/44935))

## 21.3.0 (2022-10-19)

Expand Down
5 changes: 2 additions & 3 deletions packages/components/src/tab-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ export function TabPanel( {
const selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;

useEffect( () => {
const newSelectedTab = find( tabs, { name: selected } );
if ( ! newSelectedTab && tabs.length > 0 ) {
if ( ! selectedTab?.name && tabs.length > 0 ) {
handleTabSelection( initialTabName || tabs[ 0 ].name );
}
}, [ tabs ] );
}, [ tabs, selectedTab?.name, initialTabName ] );

return (
<div className={ className }>
Expand Down

0 comments on commit c97cf39

Please sign in to comment.