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

[core] fix(OverflowList): edge case in shouldComponentUpdate #5486

Merged
merged 5 commits into from
Aug 22, 2022
Merged
Changes from 4 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
7 changes: 4 additions & 3 deletions packages/core/src/components/overflow-list/overflowList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ export class OverflowList<T> extends React.Component<OverflowListProps<T>, IOver
this.repartition();
}

public shouldComponentUpdate(_nextProps: OverflowListProps<T>, nextState: IOverflowListState<T>) {
public shouldComponentUpdate(nextProps: OverflowListProps<T>, nextState: IOverflowListState<T>) {
// We want this component to always re-render, even when props haven't changed, so that
// changes in the renderers' behavior can be reflected.
// The following statement prevents re-rendering only in the case where the state changes
// identity (i.e. setState was called), but the state is still the same when
// shallow-compared to the previous state.
return !(this.state !== nextState && shallowCompareKeys(this.state, nextState));
// shallow-compared to the previous state. Original context: https://github.com/palantir/blueprint/pull/3278.
// We also ensure that we re-render if the props DO change (which isn't necessarily accounted for by other logic).
return this.props !== nextProps || !(this.state !== nextState && shallowCompareKeys(this.state, nextState));
}

public componentDidUpdate(prevProps: OverflowListProps<T>, prevState: IOverflowListState<T>) {
Expand Down