Skip to content

fix: Selection clicking editor padding #1717

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: click-between-blocks-fix
Choose a base branch
from

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented May 23, 2025

Problem

In Chrome, clicking the editor padding on the right side of a list item block moves the selection to the block's start instead of end. This is because the list item indicators are displayed using a :before pseudo-element, which Chrome seems to prioritize over the block content element, despite it being closer to the cursor.

This ProseMirror discussion has some more information on the issue.

Solution

This PR makes the :before elements for list item indicators have a height of 0, which fixes the issue in Chrome. The elements are positioned exactly as they were before as the element's overflow is visible, and some additional rules have been added to fix the alignment that was broken from the height change.

Before:

Screen.Recording.2025-05-23.at.21.22.08.mov

After:

Screen.Recording.2025-05-23.at.21.27.16.mov

Caveats

Feels slightly hacky, but don't think it should cause any issues.

Alternatives tried

Using display: inline instead of flexbox: Added a space to the server rendered editor that couldn't be removed without hacks. Also caused an issue when the block was empty on Firefox. See this comment for both of these.

Custom selection handling logic: Was overly complex and somewhat hacky.

Copy link

vercel bot commented May 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview May 23, 2025 7:31pm
blocknote-website ❌ Failed (Inspect) May 23, 2025 7:31pm

Copy link

pkg-pr-new bot commented May 23, 2025

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@1717

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@1717

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@1717

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@1717

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@1717

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@1717

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@1717

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@1717

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@1717

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@1717

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@1717

commit: 0d4af93

/* Also have to center the text vertically to ensure alignment at different
line heights (which we change for `.bn-inline-content` below). */
display: flex;
align-items: center;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also explicitly set the overflow to show. There are many CSS resets out there so if you rely on a default behavior it may not work in some projects.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants