Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InspectorControls: Text not displayed when "Show button text labels" is enabled #61949

Merged
merged 2 commits into from
May 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
Button,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { store as preferencesStore } from '@wordpress/preferences';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -24,6 +26,10 @@ export default function InspectorControlsTabs( {
hasBlockStyles,
tabs,
} ) {
const showIconLabels = useSelect( ( select ) => {
return select( preferencesStore ).get( 'core', 'showIconLabels' );
}, [] );

// The tabs panel will mount before fills are rendered to the list view
// slot. This means the list view tab isn't initially included in the
// available tabs so the panel defaults selection to the settings tab
Expand All @@ -43,10 +49,16 @@ export default function InspectorControlsTabs( {
tabId={ tab.name }
render={
<Button
icon={ tab.icon }
label={ tab.title }
icon={
! showIconLabels ? tab.icon : undefined
}
label={
! showIconLabels ? tab.title : undefined
}
className={ tab.className }
/>
>
{ showIconLabels && tab.title }
</Button>
}
/>
) ) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
.show-icon-labels {
.block-editor-block-inspector__tabs [role="tablist"] {
.components-button.has-icon {
// Hide the button icons when labels are set to display...
svg {
display: none;
}
// ... and display labels.
// Uses ::before as ::after is already used for active tab styling.
&::before {
content: attr(aria-label);
}
.components-button {
justify-content: center;
}
}
}
Expand Down
Loading