Skip to content

Commit

Permalink
Fix Site title: Different markup in the editor and on the frontend (#…
Browse files Browse the repository at this point in the history
…29021)

Update Site Title markup in the editor
  • Loading branch information
aurooba authored Mar 17, 2021
1 parent 7f58c19 commit 3d9f76e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/block-library/src/site-title/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalSelector": ".wp-block-site-title, .wp-block-site-title > a",
"__experimentalTextTransform": true
}
}
25 changes: 12 additions & 13 deletions packages/block-library/src/site-title/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ import LevelToolbar from './level-toolbar';
export default function SiteTitleEdit( { attributes, setAttributes } ) {
const { level, textAlign } = attributes;
const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' );
const tagName = level === 0 ? 'p' : `h${ level }`;
const TagName = level === 0 ? 'p' : `h${ level }`;
const blockProps = useBlockProps( {
className: classnames( {
[ `has-text-align-${ textAlign }` ]: textAlign,
} ),
} );

return (
<>
<BlockControls>
Expand All @@ -47,17 +46,17 @@ export default function SiteTitleEdit( { attributes, setAttributes } ) {
}
/>
</BlockControls>

<RichText
tagName={ tagName }
aria-label={ __( 'Site title text' ) }
placeholder={ __( 'Write site title…' ) }
value={ title }
onChange={ setTitle }
allowedFormats={ [] }
disableLineBreaks
{ ...blockProps }
/>
<TagName { ...blockProps }>
<RichText
tagName="a"
aria-label={ __( 'Site title text' ) }
placeholder={ __( 'Write site title…' ) }
value={ title }
onChange={ setTitle }
allowedFormats={ [] }
disableLineBreaks
/>
</TagName>
</>
);
}

0 comments on commit 3d9f76e

Please sign in to comment.