Skip to content
Prev Previous commit
Next Next commit
Update edit.js
  • Loading branch information
carolinan committed Mar 9, 2023
commit 36bebd68f73145cf23232d675b2e9d473420a6f1
2 changes: 1 addition & 1 deletion packages/block-library/src/post-excerpt/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default function PostExcerptEditor( {
* the raw and the rendered excerpt depending on which is being used.
* If there is no excerpt the value is set to '' to make sure it is not undefined (See line 89).
*/
let rawOrRenderedExcerpt = rawExcerpt.trim || strippedRenderedExcerpt;
let rawOrRenderedExcerpt = rawExcerpt || strippedRenderedExcerpt;
Copy link
Member

Choose a reason for hiding this comment

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

Which excerpt variation is preferred here when we have both?

Copy link
Contributor Author

@carolinan carolinan Mar 23, 2023

Choose a reason for hiding this comment

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

Hmm yes In this case the rawExcerpt should be prioritized because it is the customized excerpt text.

Copy link
Member

Choose a reason for hiding this comment

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

I asked because the previous logic prioritized renderedExcerpt if it was available, and here we're changing the logic.

Suggestion (non-blocking): You can also use parentheses around expression and trim returned value in a single go:

const rawOrRenderedExcerpt = ( rawExcerpt || strippedRenderedExcerpt ).trim();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the previous logic was wrong and this would correct it.
Looking at the code before #44964, the rawExcerpt comes first.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the confirmation, @carolinan!

rawOrRenderedExcerpt = rawOrRenderedExcerpt.trim();

let trimmedExcerpt = '';
Expand Down