Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ class ExpandableSection extends React.Component<ExpandableSectionProps, Expandab
};

resize = () => {
const { offsetWidth } = this.expandableContentRef.current;
if (this.state.previousWidth !== offsetWidth) {
this.setState({ previousWidth: offsetWidth });
this.checkToggleVisibility();
if (this.expandableContentRef) {
const { offsetWidth } = this.expandableContentRef.current;
Comment on lines +174 to +175
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this fix work?
this.expandableContentRef is assigned as a class property:
expandableContentRef = React.createRef<HTMLDivElement>();
Therefore this.expandableContentRef is always an object. However expandableContentRef.current may be null.

Therefore shouldn't the fix be:

if (this.expandableContentRef.current) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. when i originally pushed a change i had a check to current that is missing here. I will push nother fix so it is included in our up coming release.

if (this.state.previousWidth !== offsetWidth) {
this.setState({ previousWidth: offsetWidth });
this.checkToggleVisibility();
}
}
};
handleResize = debounce(this.resize, 250);
Expand Down