-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Handling early <body> changes #1754
Conversation
// Remove from body | ||
getBodyElement().removeChild(el); | ||
// checking if element exists as the body might have been changed by thinks like 'turbolinks' | ||
const body: HTMLBodyElement = getBodyElement(); |
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 found another culprit
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.
May want to change to things instead of thinks in the comment :)
@@ -59,26 +59,6 @@ it('should remove the element when unmounting after a timeout', () => { | |||
expect(getElement('5')).not.toBeTruthy(); | |||
}); | |||
|
|||
it('should not remove the element when unmounting after a timeout if the element does not exist', () => { |
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 removed this test in favour of one that catches any issues for all the components
if (getBodyElement().contains(el)) { | ||
// not clearing the ref as it might have been set by a new effect | ||
getBodyElement().removeChild(el); | ||
// checking if element exists as the body might have been changed by thinks like 'turbolinks' |
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 think you mean things not thinks here :)
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.
thanks! changed
}); | ||
|
||
forEachSensor((control: Control) => { | ||
it('should have any errors when body is changed just before unmount: mid drag', () => { |
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.
💯 to this test. Much better sorry I should have probably just migrated it here :)
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.
All good! I wanted to get yours in and see if i could make it catch every 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.
LGTM That test is much better!
Follow up #1751
Adding a test to catch any errors caused by the body changing just before an unmount
/cc @sdb1228