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): improve spacer width check #5168

Merged
merged 1 commit into from
Mar 16, 2022
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
4 changes: 2 additions & 2 deletions packages/core/src/components/overflow-list/overflowList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class OverflowList<T> extends React.Component<OverflowListProps<T>, IOver
/** A cache containing the widths of all elements being observed to detect growing/shrinking */
private previousWidths = new Map<Element, number>();

private spacer: Element | null = null;
private spacer: HTMLElement | null = null;
Copy link
Member

Choose a reason for hiding this comment

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

Technically this no longer allows non-HTML usage of the overflow list, but given that it's relatively specific for HTML layout, I'm ok with this.


public componentDidMount() {
this.repartition(false);
Expand Down Expand Up @@ -255,7 +255,7 @@ export class OverflowList<T> extends React.Component<OverflowListProps<T>, IOver
overflow: [],
visible: this.props.items,
}));
} else if (this.spacer.getBoundingClientRect().width < 0.9) {
} else if (this.spacer.offsetWidth < 0.9) {
Copy link
Member

Choose a reason for hiding this comment

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

I tested this works in our internal repro.

// spacer has flex-shrink and width 1px so if it's much smaller then we know to shrink
this.setState(state => {
if (state.visible.length <= this.props.minVisibleItems!) {
Expand Down