Skip to content

Bug: Commands do not bubble from nested editors to parent editors #8306

@levensta

Description

@levensta

Lexical version: 0.42.0

Steps To Reproduce

  1. Create an ImageNode and add a link and/or bold text to the caption
  2. Move the cursor to formatted text or a link

Link to code example:

https://playground.lexical.dev/#doc=H4sIAAAAAAAAE-1UTWvcMBD9K2LOiu0NMcvqWig99BDYkFBKD6o1a08rS0Ya27ss-9-L7GyT7CFJk1Da0pM1I-Z9yHraAxpiH9asGUHtIXjP6Vs1ZE1AB-rzScG7DkEBtbpGkDBgiOQdqIUEbfkKtwwKPqG1fhQb60cMgpxgsixiQxsWFl0ECZXueBrc_7oGg6zJgiokbHxoNU_L1pukzKWOBQmRdzY1QALPsq4pEgtuUKTebGTauu_jIJ9mWzyH7SNuqZr2HqN6qRcx4tdIjI_Bf5FgKGA1H7Trrb0jSVDkDLqZ8BbDkvt-8lcD2uMs61Aj_6yIk6a56IMFBQ1zF1We29l6ZnDI4VUuNz4I46u3ddnpoOugu-bEasJ-fycvleujpBfQTBf5gdTDQUKDVDe3_vX2hgw3oMqikBAbP747xoJDjxJiqEBBrmNEjvluitXZHKuzQQ-rD3HA7FtXg4RxRip-13k8Iyb_Q_lPh7Jv0bFOPoR2RrQ-oCA3Q5F32R8Q2ofX5m96KSRYHXmtBzSgFstlWS7L84vVqkwPhe9DleYurd7VwffO3J-GIrs4zwo4_ABRJIvd3wcAAA

The current behavior

The toolbar does not show active buttons if the cursor is located inside a nested lexical instance (caption editor). Also in the debug view you can see that the main instance did not receive the SELECTION_CHANGE command. Therefore, the toolbar plugin does not update its state https://github.com/facebook/lexical/blob/v0.42.0/packages/lexical-playground/src/plugins/ToolbarPlugin/index.tsx#L784-L787

commands.bubbling.v0-42.mov

The expected behavior

The toolbar displays the current state of the buttons for the text in the image caption

commands.bubbling.v0-41.mov

Impact of fix

It seems this behavior was influenced by this PR #8202

The description says:

Unhandled dispatched commands are now only bubbled to parent editors if the parent editor is not currently in an update

I couldn't find the specific code responsible for delegating events to the parent editor, but I'll note that I caught this bug in an editor that doesn't use extensions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions