Skip to content

Commit

Permalink
Post Editor: fix click space after post content to append (#64992)
Browse files Browse the repository at this point in the history
* Fix minimally

* Revise comment

* Stop propagation and don’t prevent default

* Insert default block if no blocks are present
  • Loading branch information
stokesman committed Sep 4, 2024
1 parent 04cf579 commit c2b0226
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ function useEditorStyles() {
? editorSettings.styles ?? []
: defaultEditorStyles;

// Add a constant padding for the typewriter effect. When typing at the
// bottom, there needs to be room to scroll up.
// Add a space for the typewriter effect. When typing in the last block,
// there needs to be room to scroll up.
if (
! isZoomedOutView &&
renderingMode === 'post-only' &&
Expand Down
15 changes: 5 additions & 10 deletions packages/edit-post/src/components/layout/use-padding-appender.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export function usePaddingAppender() {
const { ownerDocument } = node;
const { defaultView } = ownerDocument;

const paddingBottom = defaultView.parseInt(
defaultView.getComputedStyle( node ).paddingBottom,
const pseudoHeight = defaultView.parseInt(
defaultView.getComputedStyle( node, ':after' ).height,
10
);

if ( ! paddingBottom ) {
if ( ! pseudoHeight ) {
return;
}

Expand All @@ -38,25 +38,20 @@ export function usePaddingAppender() {
return;
}

event.preventDefault();
event.stopPropagation();

const blockOrder = registry
.select( blockEditorStore )
.getBlockOrder( '' );
const lastBlockClientId = blockOrder[ blockOrder.length - 1 ];

// Do nothing when only default block appender is present.
if ( ! lastBlockClientId ) {
return;
}

const lastBlock = registry
.select( blockEditorStore )
.getBlock( lastBlockClientId );
const { selectBlock, insertDefaultBlock } =
registry.dispatch( blockEditorStore );

if ( isUnmodifiedDefaultBlock( lastBlock ) ) {
if ( lastBlock && isUnmodifiedDefaultBlock( lastBlock ) ) {
selectBlock( lastBlockClientId );
} else {
insertDefaultBlock();
Expand Down

0 comments on commit c2b0226

Please sign in to comment.