-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
getAutocompleterUI: don't redefine ListBox component on every render #61877
Conversation
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.
Wouldn't be bad if it also adds an e2e test to the existing suite of autocomplete tests
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @17cliu. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
) ) } | ||
</Component> | ||
); | ||
} |
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.
Do we need it to be inside of getAutoCompleterUI
?
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.
It can be outside! Moved 🙂
Flaky tests detected in d166614. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9203507985
|
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.
Works fine for me. Also fixes this issue: #55299.
e0eed38
to
d166614
Compare
Good idea, added a test that autocompletes inside a table. Verified that it fails on trunk and succeeds after the fix. I think I addressed all feedback, going to merge now. |
Size Change: +35 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
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.
Really nice one, @jsnajdr 🙌
…ordPress#61877) * getAutocompleterUI: don't redefine ListBox component on every render * Move ListBox to top level * Add components changelog entry * Add e2e test for autocomplete inside table Unlinked contributors: 17cliu. Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: alexstine <alexstine@git.wordpress.org> Co-authored-by: johngodley <johnny5@git.wordpress.org>
…ordPress#61877) * getAutocompleterUI: don't redefine ListBox component on every render * Move ListBox to top level * Add components changelog entry * Add e2e test for autocomplete inside table Unlinked contributors: 17cliu. Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: alexstine <alexstine@git.wordpress.org> Co-authored-by: johngodley <johnny5@git.wordpress.org>
Fixes #50562. The
AutocompleterUI
component defined a nestedListBox
component inside its render function, but this is an antipattern! TheListBox
component has different identity on every render, and that causes it to completely unmount and remount on every render.One of the symptoms is that the
onClick
handler on theButton
subcomponents in theListBox
is never called when the autocompleter is inside the table. Don't ask me why 🙂 There is probably some chaotic unstable rerendering that destroys theonClick
handler before it gets a chance to be called.Another symptom that you can easily reproduce is that the gravatar image on the user autocomplete is blinking as you type. Because the items are not rendered in a stable way, the
img
element gets repeatedly destroyed and created and loaded again.How to test:
Verify that the symptoms reported in #50562 (user autocomplete inside table cell) are fixed. Also, the gravatar images should be stabilized.