Fix bullets merging with prior elements on Firefox when the first node is removed#1280
Merged
Merged
Conversation
There was a problem hiding this comment.
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#findLocationFromContainerAndOffsetto 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 fordeleteContentBackwardin a bullet list. - Mirror the same fix into the vendored
action_text-trixcompiledtrix.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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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