-
Notifications
You must be signed in to change notification settings - Fork 843
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
Fix: accordion observer issues #982
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.
code LGTM; will address further in #966 which refactors the mutation observer usage in EUI
@@ -50,6 +50,13 @@ export class EuiAccordion extends Component { | |||
this.setChildContentHeight(); | |||
} | |||
|
|||
componentWillUnmount() { |
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.
have you observed a case when the observer isn't disconnected? ref
functions are [normally] called with null
as the children components unmount, and the accordion's setChildContentRef
is setup to respond accordingly
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.
Oh, that's a good point. I didn't think ref got recalculated on unmount. If that's true, then the componentWillUnmount
hook isn't actually required. Is that also true with the new ref API in 16.3+?
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.
For the record, it does indeed call the ref function with null
on unmount. I've closed that issue and removed that code from this PR.
I wasn't aware of that, and I'm still curious if the new ref API in 16.3 works the same way.
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.
16.3 works the same way, only changes to refs in that version is the addition of the forwardRef
API. Thanks for testing!
Thanks for the PR! |
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
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.
Needs Bug Fix added to changelog
@chandlerprall hopefully I did that right... |
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.
please move the changelog line into the **Bug fixes** section immediately below it
@w33ble requested a small placement change to the changelog, then this will be great to get in! |
@chandlerprall any chance you're planning to cut a bugfix release this week? |
8aa3a03
to
2e6f498
Compare
don't attempt to read the clientHeight if it's no assigned
before trying to use setAttribute
2e6f498
to
3f29698
Compare
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! thanks!
@w33ble feel free to merge, I'll cut a release when this is in |
Quick fix for #981
Mostly a quick patch to the Accordion so that the mutation observer stops causing uncaught errors.
setChildContentHeight
, check thatthis.childContent
is truthy before trying to read theclientHeight
propertysetChildContentHeight
, check thatthis.childWrapper
is set before trying to usesetAttribute