Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix bullets merging with prior elements on Firefox when the first node is removed#1280

Merged
flavorjones merged 1 commit into
mainfrom
fix-bullets-merging-with-prior-element
Mar 3, 2026
Merged

Fix bullets merging with prior elements on Firefox when the first node is removed#1280
flavorjones merged 1 commit into
mainfrom
fix-bullets-merging-with-prior-element

Conversation

@monorkin
Copy link
Copy Markdown
Contributor

This fixes a bug whereby selecting nodes at the start of a list and removing them causes the bullet to disappear and the remaining content to merge with the prior node.

Bug in action:

Screen.Recording.2026-02-27.at.10.31.16.am.mov

Fix in action:

screenrecording-2026-02-27_21-01-55.mp4

This should also fix: #1259

Copilot AI review requested due to automatic review settings February 27, 2026 20:02
@monorkin monorkin changed the title Fix bullets merging with prior elements when the first node is removed Fix bullets merging with prior elements on Firefox when the first node is removed Feb 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an issue in Trix’s DOM-to-document location mapping that could miscompute the block index when a browser reports an element-level range start (e.g., Firefox starting a range at <li> with offset 0). This prevents list bullets from disappearing and content from incorrectly merging into the prior block when deleting/cutting at the start of a list item.

Changes:

  • Adjust LocationMapper#findLocationFromContainerAndOffset to account for a block-start node before breaking when mapping non-strict element/offset boundaries.
  • Add a system test that simulates Firefox’s element-level beforeinput.getTargetRanges() behavior for deleteContentBackward in a bullet list.
  • Mirror the same fix into the vendored action_text-trix compiled trix.js.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/trix/models/location_mapper.js Ensures non-strict mapping counts a block start when the container is an element and the offset boundary hits a block-start node, avoiding off-by-one block indexing.
src/test/system/level_2_input_test.js Adds regression coverage for Firefox-style element-level target ranges during backward deletion in bullet lists.
action_text-trix/app/assets/javascripts/trix.js Applies the same location-mapping fix to the vendored/compiled ActionText Trix bundle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@flavorjones flavorjones left a comment

Choose a reason for hiding this comment

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

Nice fix!

@flavorjones flavorjones merged commit d9dbf0a into main Mar 3, 2026
24 checks passed
@flavorjones flavorjones deleted the fix-bullets-merging-with-prior-element branch March 3, 2026 14:11
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.

Issue Cutting and Pasting from Ordered/Unordered Lists in Firefox and Chrome

3 participants