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.
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.
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:
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:
- Create a new ElementNode called TableWrapper or something like that.
- Use DecoratorElementNode if this PR ends up being approved: feat(core): add experimental decorator element node and nested root node facebook/lexical#5981
- Use a DecoratorNode. Inside, you could use a nested lexicalEditor that only contains a table, or you could even use a more powerful third-party table library.
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.
- npx create-payload-app@beta --use-pnpm -t website
- pnpm install
- pnpm dev
- Go to a page at http://localhost:3000/admin/collections/pages
- Create a table with multiple columns or resize them to take up a lot of space
Adapters and Plugins
No response