Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table Overflow in Lexical #8036

Open
GermanJablo opened this issue Sep 2, 2024 · 3 comments
Open

Table Overflow in Lexical #8036

GermanJablo opened this issue Sep 2, 2024 · 3 comments
Assignees
Labels
plugin: richtext-lexical @payloadcms/richtext-lexical status: verified If an issue has been reproduced

Comments

@GermanJablo
Copy link
Contributor

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

@GermanJablo GermanJablo added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Sep 2, 2024
@AlessioGr AlessioGr added status: verified If an issue has been reproduced plugin: richtext-lexical @payloadcms/richtext-lexical labels Sep 3, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Sep 3, 2024
@GermanJablo
Copy link
Contributor Author

I have no faith that option 2 will ever materialize, and even then I don't think it would be the best option.

A DecoratorNode would introduce quite a bit of complexity (nested editors, new boundaries in the selection, problems with the undo manager, etc.).

I think the best thing to do would be to add a TableWrapperNode of type ElementNode which renders as a div.

We could easily force the schema in a backwards-compatible way using lexical transforms.

If the Lexical team agrees with the solution and is interested, I will implement it in their repository, if not, I will do it in ours.

What do you think, @AlessioGr?

GermanJablo added a commit that referenced this issue Sep 26, 2024
…rflow). (#8431)

This is a half-baked and temporary solution to
#8036

As I said there:
- ideally tables would have a horizontal scroll independent of the rest
of the document, just like Notion does.
- the solution in this PR can make the experience of resizing columns
frustrating

However, despite that drawback, it is arguably a better behavior than
the current one where they can have overflow over the editor container.

Until the ideal solution is implemented, let's default to this behavior.

## Before


![image](https://github.com/user-attachments/assets/b2856a3f-4b43-45f0-a7db-00c53fe5c980)


## After

![image](https://github.com/user-attachments/assets/2f60d186-d614-4c72-968c-137820812e11)
@denolfe
Copy link
Member

denolfe commented Sep 27, 2024

Should we close this @GermanJablo ?

@GermanJablo
Copy link
Contributor Author

not yet. The linked PR is a temporary solution. But I'm campaigning to finish this soon

@GermanJablo GermanJablo self-assigned this Oct 1, 2024
@denolfe denolfe removed the v3 label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: richtext-lexical @payloadcms/richtext-lexical status: verified If an issue has been reproduced
Projects
None yet
Development

No branches or pull requests

3 participants