Skip to content

Bug: Programmatically moving a Selection does not update the Formatting nor Style #8817

Description

@ssoelvsten

When moving the selection programmatically, the formatting and style does not seem to be updated for its new position.

Lexical version: 0.44+ (possibly even earlier)

Steps To Reproduce

  1. Select some text with some formatting (e.g. "bold" via dispatchCommand) or style (e.g. via $patchStyleText).
  2. Trigger a getRoot().selectStart(), getRoot().selectEnd() or similar programmatic movement of the selection.

Link to code example:
https://stackblitz.com/edit/github-zdwwiaov?file=src%2Fmain.ts

The current behavior

The values in $getSelection().hasFormat(...) or $getSelectionStyle($getSelection(), ...) still report the values for the formatting/style from step 1.

The expected behavior

The formatting/style should reflect the new position of the selection from step 2. That would align with its behavior if the selection was moved with a mouse click or a keyboard command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions