Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Add pattern title to the Pattern Block sidebar panel heading #197

Merged
merged 1 commit into from
Jun 15, 2023
Merged
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
Add pattern title to the Pattern Block sidebar panel heading
Conditionally shows the pattern title as heading in the sidebar once a pattern is selected.
  • Loading branch information
dreamwhisper committed Jun 15, 2023
commit b6a3f9e24bfc3f45181bf97d6a4e57a539e91919
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ function PatternInspector( { pattern }: PatternInspectorProps ) {
<InspectorControls>
<Panel>
<PanelBody
title={ __( 'Pattern', 'pattern-manager' ) }
title={
pattern
? pattern.title
: __( 'Pattern', 'pattern-manager' )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't better, but here's another way to do this:

title={ pattern?.title ?? __( 'Pattern', 'pattern-manager' ) }

Don't change this.

I just thought I'd share it, as I'm learning about the ?? operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kienstra!

Appreciate the info too!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

}
initialOpen={ true }
>
<p>
Expand Down