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

Feature: Proper Handling of Deletions Across Adjacent Unmergeable Text Spans in Grid Containers #7301

Open
birtles opened this issue Mar 6, 2025 · 0 comments
Labels
enhancement Improvement over existing feature

Comments

@birtles
Copy link
Contributor

birtles commented Mar 6, 2025

Description

When deleting across adjacent unmergeable text spans inside a display: inline-grid (or presumably display: grid) container, Lexical does not properly extend the selection into the next span, causing deletion to get stuck.

Previously, it was possible to work around this issue by manually extending the selection when deleting across boundaries (see span-deletion.ts), but this workaround no longer functions in Lexical 0.27.0+ due to a change in selection syncing (related change).

The expected behavior is for RangeSelection.modify to correctly move from the edge of one text node to the next before applying the native selection change, similar to $modifySelectionAroundDecoratorsAndBlocks.

Steps to Reproduce

A minimal reproduction can be found here: StackBlitz.

  1. Position the caret between "A" and "B".
  2. Press Del to delete "B".
  3. Press Del again.

Expected Results

  • Both "B" and "C" should be deleted sequentially.

Actual Results

  • Deletion gets stuck either at "B" or at "C" (it depends on if the caret initially lies at the start of the "B" span or the end of the "A" span).

This only occurs when using display: inline-grid. Disabling inline-grid allows deletion to function normally.

Use cases

  • Any applications requiring adjacent text nodes inside a container like display: grid (ruby text editing in our case)

Alternative Solutions Considered

  • Manually adjusting the selection before deletion (which worked in 0.26 but no longer works in 0.27 due to the updated selection syncing behavior).
  • Finding an alternative layout approach that avoids using grid etc. (In our specific case, browser support for ruby layout has come a long way since we started but still only Firefox supports the necessary HTML tags to render mono ruby without interleaving the transcription nodes.)

Impact

  • This affects developers working with custom nodes that put multiple adjacent (unmergeable) text nodes inside certain containers (at least display: inline-grid but possibly others like display: flex too).
  • The issue prevents deletion across text spans, breaking expected editor behavior.
  • Fixing this would improve selection handling and deletion reliability in specialized text-editing scenarios.

(As discussed with @etrepum on Discord)

@birtles birtles added the enhancement Improvement over existing feature label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement over existing feature
Projects
None yet
Development

No branches or pull requests

1 participant