Skip to content

Bug: TablePlugin: Delete key commands handling - $deleteCellHandler doen't check is current selection in target table #6972

@Ulop

Description

@Ulop

Lexical version: 0.21.0

Steps To Reproduce

  1. Open playground
  2. Remove all content
  3. Append first table
  4. Append some text
  5. Append second table
  6. Select all cell's of second table
  7. Press Del

The current behavior

First table removed

The expected behavior

Second table removed

Most command handlers in TableSelectionHelpers.ts check via $isSelectionInTable is current selection($getSelection()) point to target table node passed to applyTableHandlers.
This check is missing in the $deleteCellHandler method.

This results in the command handler being triggered only for the first table registered for subsequent commands.

for (const command of DELETE_KEY_COMMANDS) {
    tableObserver.listenersToRemove.add(
      editor.registerCommand<KeyboardEvent>(
        command,
        $deleteCellHandler,
        COMMAND_PRIORITY_CRITICAL,
      ),
    );
  }
table_remove.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions