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

Post Editor: fix click space after post content to append #64992

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
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
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
Loading