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

Make default block appender appear more consistently. #28529

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -75,22 +75,22 @@ export function DefaultBlockAppender( {
export default compose(
withSelect( ( select, ownProps ) => {
const {
getBlockAttributes,
getBlockCount,
getBlockName,
isBlockValid,
getSettings,
getTemplateLock,
} = select( blockEditorStore );

const isEmpty = ! getBlockCount( ownProps.rootClientId );
const isLastBlockDefault =
const isLastBlockEmptyDefault =
getBlockName( ownProps.lastBlockClientId ) ===
getDefaultBlockName();
const isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );
getDefaultBlockName() &&
getBlockAttributes( ownProps.lastBlockClientId )?.content === '';
Copy link
Member

Choose a reason for hiding this comment

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

Should we use isUnmodifiedDefaultBlock here?

Copy link
Member

Choose a reason for hiding this comment

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

(No guarantee that the default block has the content attribute and that it means the blocks is empty.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that I think about it, perhaps I should only be checking for the Paragraph block specifically? The whole point of this conditional is to handle the case where an empty Paragraph shows an appender inside it. Is that behavior unique to the Paragraph?

const { bodyPlaceholder } = getSettings();

return {
isVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,
isVisible: isEmpty || ! isLastBlockEmptyDefault,
showPrompt: isEmpty,
isLocked: !! getTemplateLock( ownProps.rootClientId ),
placeholder: bodyPlaceholder,
Expand Down
1 change: 0 additions & 1 deletion packages/e2e-tests/specs/editor/various/links.test.js
Expand Up @@ -465,7 +465,6 @@ describe( 'Links', () => {
// Confirm that submitting the input without any changes keeps the same
// value and moves focus back to the paragraph.
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.type( '.' );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
Expand Down