Skip to content

Fix: accordion observer issues#982

Merged
w33ble merged 3 commits into
masterfrom
fix/accordion-observer-issues
Jul 10, 2018
Merged

Fix: accordion observer issues#982
w33ble merged 3 commits into
masterfrom
fix/accordion-observer-issues

Conversation

@w33ble
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/components/accordion/accordion.js Outdated
this.setChildContentHeight();
}

componentWillUnmount() {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Thanks for the PR!

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

w33ble commented Jul 10, 2018

@chandlerprall hopefully I did that right...

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

@w33ble
Copy link
Copy Markdown
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
w33ble added 3 commits July 10, 2018 14: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
Copy Markdown
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
Copy Markdown
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