Skip to content

Bug: Table header status is not set correctly on table header columns #8090

@zoltanhosszu

Description

@zoltanhosszu

When importing a table with column headers, the TableCellHeaderStatus is not set correctly.

Link to relevant code in Lexical codebase:
https://github.com/facebook/lexical/blob/30ada8475a779d3c7ded4323b8782f1d5483430c/packages/lexical-table/src/LexicalTableCellNode.ts#L341C1-L347C5

Steps To Reproduce

Set this as the editor value:

<table>
  <tr>
    <th><p>Name</p></th>
    <td><p>Email</p></td>
  </tr>
  <tr>
    <th><p>Alice</p></th>
    <td><p>alice@example.com</p></td>
  </tr>
</table>

Add a new row with $insertTableRowAtSelection(). The new row will be this:

...
  <tr>
    <td></td>
    <td></td>
  </tr>
</table>

Instead, it should be:

...
  <tr>
    <th></th>
    <td></td>
  </tr>
</table>

The current behavior

Table column headers can only get TableCellHeaderStates.ROW status.

The expected behavior

Table column headers should get TableCellHeaderStates.COLUMN or TableCellHeaderStates.BOTH if it's a header column.

Impact of fix

Editing existing tables with header column will be correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    tablesRelates to Lexical Tables

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions