Skip to content
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

Merged
merged 3 commits into from
Jul 10, 2018
Merged

Conversation

w33ble
Copy link
Contributor

@w33ble w33ble commented Jul 9, 2018

Quick fix for #981

Mostly a quick patch to the Accordion so that the mutation observer stops causing uncaught errors.

  • in setChildContentHeight, check that this.childContent is truthy before trying to read the clientHeight property
  • in setChildContentHeight, check that this.childWrapper is set before trying to use setAttribute

@cchaos cchaos requested a review from chandlerprall July 9, 2018 20:10
Copy link
Contributor

@chandlerprall chandlerprall left a 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() {
Copy link
Contributor

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

Copy link
Contributor Author

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+?

Copy link
Contributor Author

@w33ble w33ble Jul 9, 2018

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.

Copy link
Contributor

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!

@chandlerprall
Copy link
Contributor

Thanks for the PR!

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@chandlerprall chandlerprall left a 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

@w33ble
Copy link
Contributor Author

w33ble commented Jul 10, 2018

@chandlerprall hopefully I did that right...

Copy link
Contributor

@chandlerprall chandlerprall left a 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

@chandlerprall
Copy link
Contributor

@w33ble requested a small placement change to the changelog, then this will be great to get in!

@w33ble
Copy link
Contributor Author

w33ble commented Jul 10, 2018

@chandlerprall any chance you're planning to cut a bugfix release this week?

@w33ble w33ble force-pushed the fix/accordion-observer-issues branch from 8aa3a03 to 2e6f498 Compare July 10, 2018 21:14
don't attempt to read the clientHeight if it's no assigned
before trying to use setAttribute
@w33ble w33ble force-pushed the fix/accordion-observer-issues branch from 2e6f498 to 3f29698 Compare July 10, 2018 21:15
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks!

@chandlerprall
Copy link
Contributor

@w33ble feel free to merge, I'll cut a release when this is in

@w33ble w33ble merged commit 7f8d23c into master Jul 10, 2018
@chandlerprall chandlerprall deleted the fix/accordion-observer-issues branch July 19, 2018 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants