-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[lexical-table] feat: Add row striping #6547
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
@etrepum could you help me on this one, there something happening on a deeper level that I'm unable to pin down. If you run my branch and create a table -> enable row striping -> disable row striping (or add col header, etc.) it would crash, because it can no longer find a table observer. Not urgent, when you have some free time. |
@ivailop7 I've added a commit that I think fixes the issue you're having, I did not do the rebase/conflict resolution |
It does work, thanks Bob. A very interesting commit. I'll handle the remaining details. |
I think the root cause was the incorrect type and management of the property that's added to the element and it's just a cast so there was no compiler checking. I added the abort signal because I also noticed that the listener cleanup there wasn't comprehensive when auditing the code. Probably would be better off moving most of that code out of effects for cross-platform and just simplicity reasons. |
When you say property, do you mean the TableNode rowStriping one? Unfortunately, the issue seems to be still there. As in table selection gets broken after toggling row striping, no highlight shows up when doing a table selection or cells resizing works, until you do a table selection and then resizing cells works, so the event of enabling rowStriping is still the breaking point. I do suspect it has to do with introducting of TableNode 'updateDOM' not being false all the time now and the observer is missing that rerender and things get out of sync. |
I meant the property attached to HTMLElement to store the TableObserver. Can you type up repro steps for what's happening now? |
|
@etrepum let me know, if you still are struggling replicating. Will do a recording. |
I've just been AFK all day, asked for repro instructions to save time for when I am back at a computer |
Sure, no rush. Appreciate the help here. |
It looks like the problem is the updateDOM returning true, which creates a new HTMLElement and does not initialize a new TableObserver. Mutation listeners are kind of a bad abstraction for managing DOM because "update" could mean that an in-place DOM update occurred OR that the DOM was replaced (e.g. logically destroy then create would make more sense for this case, at least as far as DOM tracking goes). The simplest fix is to make the DOM update row striping in-place. |
I've added a commit that does both fixes, the in-place update is more efficient and would've required less changes by itself. I thought it also made sense to handle updateDOM true case to demonstrate how to do it correctly and in case it's subclassed with an updateDOM that can return true. |
Totally missed the mutation listener was only doing the 'create' event. Thank you for fixing this in-place as well. 🚀 |
This is ready for review, can I get a review. Big shout out to Bob for helping on the Table Observer issues. @etrepum @zurfyx @potatowagon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! but of course I had a hand in fixing some of the edge cases so it's probably worth another set of eyes
Adding support for row striping, increases tables visual accessiblity.
row_striping.mov