-
-
Notifications
You must be signed in to change notification settings - Fork 926
Allow additional async redraw even if the first redraw is skipped #3021
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
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.
I missed this during the first review, but while we're at it, can you make sure to skip redraws after the component is removed, so removals don't trigger further redraws? (This bug also exists with sync event handlers, being able to fire events post-removal, and we should fix both in a single step.)
You should be able to get away with just doing this:
- Add a
if (self._ != null)
check to the condition in the resolver handler whereself
is the outer event listener object. - Add an
if (vnode.events != null) vnode.events._ = null
right before this line.
That'd fix both.
@dead-claudia Thanks for your review. With this commit, I removed the |
@dead-claudia I was curious about the difference in the number of assertions, so I rebased the commits just to be sure, but the result was not changed. Edit: The number of assertions may have been different for #3020. |
That's a good catch. Filed MithrilJS/infra#69 to track it down. (This is in a common workflow script.) |
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.
See comments.
Should hopefully be the last request for changes.
@@ -884,4 +916,48 @@ o.spec("event", function() { | |||
}) | |||
}) | |||
}) | |||
o("avoid sync redraw after removal", function() { |
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.
Can you extend this test to also verify the event listener itself wasn't called?
That way, we know it couldn't possibly attempt an async redraw later.
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.
I added assertions about whether the event listener itself was called or not.
The event listener itself is not removed and will be called, but it should be clearer that redraw is not being called.
o(redraw.callCount).equals(1) | ||
o(redraw.this).equals(undefined) | ||
o(redraw.args.length).equals(0) |
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.
Can you also assert thenCB
is set? That being set also implies that the event listener was actually called.
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.
OK, added the following assertions.
- Whether the event listener itself has been called or not.
- Whether thenCB was set or not.
render(root, div) | ||
div.dom.dispatchEvent(e) | ||
|
||
o(redraw.callCount).equals(0) |
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.
Can you also assert thenCB
is set? That being set also implies that the event listener was actually called.
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.
ditto
This makes it clear that the event listener is being called but redraw is not being called.
@dead-claudia Thanks for your kind review. Of course I have confirmed all tests pass (with my local |
Description
This PR allows asynchronous redraw processing even if the first redraw is skipped by setting
event.redraw=false
before await in the async function.Also, this PR avoids redraw after the dom or component is removed.
Motivation and Context
This PR is intended to address the following cases of zulip
In #3020 , I didn't consider the case where
event.redraw
would later betrue
.How Has This Been Tested?
npm run test
with additional testTypes of changes
Checklist