Skip to content

Table Overflow in Lexical #8036

Closed
@GermanJablo

Description

Link to reproduction

https://github.com/payloadcms/payload

Environment Info

Payload: 3.0.0-beta.94
Node.js: 20.17.0
Next.js: 15.0.0-canary.104

Describe the Bug

Incorrect behaviors

Having tables overflow is a mistake, as their content can conflict with other elements of the interface, as is now happening in Payload.

cleanshot_2024-08-27_at_14 59 58

Another incorrect behavior is the one that occurs in the Lexical Playground, where if the table is too large, the entire editor becomes larger. The horizontal scroll bar is not placed over the table, but over the entire content.

image

A half-way solution

A super quick way to fix overflow is to add a max-width of 100% to the table.

The problem is, as this user noted, that this creates conflicts with the column width property.

This is what OneNote does and I've always hated it. Sometimes columns resize in a magical or hard-to-understand way. It's better to give the user the flexibility to adjust column widths to their liking and to have overflow if needed.

The correct solution

The correct solution to this is for tables to have an overflow scroll independent of the rest of the editor, similar to what Notion does:

image

The problem is that the <table> tag doesn't support overflow: scroll. A div is needed to wrap it.

There is an issue opened on Lexical with recent movement about this Issue: facebook/lexical#6480

The solution will have to be:

Reproduction Steps

It can be reproduced anywhere with a Lexical editor. But the problem is more evident when there is a field with a sidebar position as in the image, since the elements overlap.

  1. npx create-payload-app@beta --use-pnpm -t website
  2. pnpm install
  3. pnpm dev
  4. Go to a page at http://localhost:3000/admin/collections/pages
  5. Create a table with multiple columns or resize them to take up a lot of space

Adapters and Plugins

No response

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions