Skip to content

Commit 65a8221

Browse files
committed
implement feedback
1 parent b5cd94e commit 65a8221

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • packages/edit-site/src/components/sidebar-edit-mode

‎packages/edit-site/src/components/sidebar-edit-mode/index.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const FillContents = ( {
4848
// This effect addresses a race condition caused by tabbing from the last
4949
// block in the editor into the settings sidebar. Without this effect, the
5050
// selected tab and browser focus can become separated in an unexpected way.
51+
// (e.g the "block" tab is focused, but the "post" tab is selected).
5152
useEffect( () => {
5253
const tabsElements = Array.from(
5354
tabListRef.current?.querySelectorAll( '[role="tab"]' ) || []
@@ -163,9 +164,15 @@ export function SidebarComplementaryAreaFills() {
163164
sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
164165
}
165166

167+
// `newSelectedTabId` could technically be falsey if no tab is selected (i.e.
168+
// the initial render) or when we don't want a tab displayed (i.e. the
169+
// sidebar is closed). These cases should both be covered by the `!!` check
170+
// below, so we shouldn't need any additional falsey handling.
166171
const onTabSelect = useCallback(
167172
( newSelectedTabId ) => {
168-
enableComplementaryArea( STORE_NAME, newSelectedTabId );
173+
if ( !! newSelectedTabId ) {
174+
enableComplementaryArea( STORE_NAME, newSelectedTabId );
175+
}
169176
},
170177
[ enableComplementaryArea ]
171178
);

0 commit comments

Comments
 (0)