Skip to content

Commit

Permalink
Fix: LineHeightControl is not disabled at the global styles block lev…
Browse files Browse the repository at this point in the history
…el (#26778)
  • Loading branch information
jorgefilipecosta authored Nov 6, 2020
1 parent f66ebf8 commit 26dc308
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/edit-site/src/components/sidebar/typography-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ import { __ } from '@wordpress/i18n';
*/
import { useEditorFeature } from '../editor/utils';

export function useHasTypographyPanel( { supports } ) {
return supports.includes( 'fontSize' ) || supports.includes( 'lineHeight' );
export function useHasTypographyPanel( { supports, name } ) {
return (
useHasLineHeightControl( { supports, name } ) ||
supports.includes( 'fontSize' )
);
}

function useHasLineHeightControl( { supports, name } ) {
return (
useEditorFeature( 'typography.customLineHeight', name ) &&
supports.includes( 'lineHeight' )
);
}

export default function TypographyPanel( {
Expand All @@ -28,6 +38,7 @@ export default function TypographyPanel( {
name
);
const fontFamilies = useEditorFeature( 'typography.fontFamilies', name );
const hasLineHeightEnabled = useHasLineHeightControl( { supports, name } );

return (
<PanelBody title={ __( 'Typography' ) } initialOpen={ true }>
Expand All @@ -50,7 +61,7 @@ export default function TypographyPanel( {
disableCustomFontSizes={ disableCustomFontSizes }
/>
) }
{ supports.includes( 'lineHeight' ) && (
{ hasLineHeightEnabled && (
<LineHeightControl
value={ getStyleProperty( name, 'lineHeight' ) }
onChange={ ( value ) =>
Expand Down

0 comments on commit 26dc308

Please sign in to comment.