-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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] Bug Fix: Enable observer updates on table elements attributes change #6479
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
Wouldn't you want a new test that shows that this functionality works, and to prevent a regression in the future? |
I wouldn't mind to add more tests. Though I am not quite sure how to approach it here. This is internal table observer configuration and it doesn't affect any existing table cases. The only way to test it would be creating a table node override and run e2e test against that new node. The whole setup would require a reasonable example of such node to be contributed into playground and new tests added. Fairly large effort and I don't feel it worth it and I frankly can see any example of such testing in the repository (I mean testing extra beviour in overriden nodes). Probably if this change go through and I'm able to implement a custom table node with the logic based on attibute changes on my side I would be able to contribute back as example for playground. |
It looks like MutationObserver should be supported by jsdom so you may be able to write a unit test for it without changing the playground at all |
Yes, jsdom supports, but it doesn't seem to be helpful in this case. Here're few things:
Again, I am totally for writing unit and e2e tests, but in this particular case it's just not reasonable. P.S. If you think it's required to have tests for changes in TableObserver, probably new issue must be created and this one marked as blocked until there is a minimal required coverage. wdyt? |
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, tests can be added separately the next time TableObserver is updated
Description
Now table observer doesn't listen to table DOM element attibutes updates. So when attempting to extend table node with features that require table element attibute updates (for example adding/remoing classes to table element) it won't re-render table.
This change will enable observer to listen to attibutes changes as well as to changes in children.
Closes #6410
Details on the topic
Here's documentation about mutation observer: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe
attributes is set to
false
by default and setting it totrue
will watch for changes to the value of attributes on the node or nodes being monitored.In case we can't enable all attibutes, it should be possible to upgrade table creation payload to include attribute names filter to enable monitoring only specified attributes for those who needs it by passing names to attributeFilter
Test plan
No new tests seem to be needed. All unit tests and e2e tests pass. No changes to existing table functionality.