Skip to content

fix: Selection clicking editor padding #1717

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

Merged
merged 10 commits into from
Jun 12, 2025
Merged

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 🛑 Canceled (Inspect) Jun 12, 2025 0:08am
blocknote-website ✅ Ready (Inspect) Visit Preview Jun 12, 2025 0:08am

Copy link

pkg-pr-new bot commented May 23, 2025

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/mantine

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@1717

@blocknote/xl-docx-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

commit: 570ae75

@matthewlipski matthewlipski changed the base branch from click-between-blocks-fix to main June 12, 2025 11:28
@matthewlipski matthewlipski merged commit 81088d5 into main Jun 12, 2025
8 checks passed
@matthewlipski matthewlipski deleted the click-editor-padding-fix branch June 12, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants