-
Notifications
You must be signed in to change notification settings - Fork 10
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
Ensure that field components do not get recreated when state changes #860
Ensure that field components do not get recreated when state changes #860
Conversation
Test Results448 tests +8 444 ✔️ +8 5m 14s ⏱️ -16s Results for commit e42dc22. ± Comparison against base commit 475c42e. This pull request removes 2 and adds 10 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
Hm, looks like this breaks a couple of critical tests. I am not sure why the fields are not updating when assigning to the card instance programatically. I'm checking but have no good clue for now |
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.
Tested the ContainsMany input field and I can type! Looks good to me except the tests
let getComponents = () => | ||
model.children.map((child) => | ||
getBoxComponent(cardTypeFor(field, child), format, child, field, context), | ||
); // Wrap the the components in a function so that the template is reactive to changes in the model (this is essentially a helper) |
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.
nice!
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.
looks great!
This is a result of pairing with @ef4 yesterday -
The issue we were solving is a bug where the "contains many" editor component will lose focus after inputting a single character, making it impossible to write a word in one go:
It turns out the whole editor component got replaced (i.e. we could see that the id in
<div id="ember102"...
got replaced) in DOM after state changes. The fix is that we now cache the components by field name, using the same technique we already use ingetBoxComponent
.We were thinking about the possibilities about adding a test for this, but we don't actually know enough about the source of this problem. The described bug reproduction is one way to see the bug, but we assume that this is only one case among many, and that the glimmer engine is usually smart enough to not recreate components (but not in this case)...