From d0dfc656e6fa04274830997caf3661561fdb28b3 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 2 Sep 2022 11:21:36 +0200 Subject: [PATCH] Improved the scrolling UX in list widgets - Fixed scrollbar does not reach end of list widget. - Estimated row heights to provide better scroll UX. - Last item's `` won't be visible even if the mouse cursor is over the `
`. + // See https://github.com/bvaughn/react-virtualized/blob/005be24a608add0344284053dae7633be86053b2/source/Grid/Grid.js#L38-L42 + scrollingResetTimeInterval={0} /> ); }} @@ -77,13 +89,13 @@ export class ComponentList extends React.Component< override componentDidUpdate(prevProps: ComponentList.Props): void { if ( this.resizeAllFlag || - !sameAs(this.props.items, prevProps.items, this.props.itemLabel) + !sameAs(this.props.items, prevProps.items, 'name', 'installedVersion') ) { this.clearAll(true); } } - private setListRef = (ref: List | null): void => { + private readonly setListRef = (ref: List | null): void => { this.list = ref || undefined; }; @@ -98,17 +110,7 @@ export class ComponentList extends React.Component< } } - private clear(index: number): void { - this.cache.clear(index, 0); - this.list?.recomputeRowHeights(index); - // Update the last item if the if the one before was updated - if (index === this.props.items.length - 2) { - this.cache.clear(index + 1, 0); - this.list?.recomputeRowHeights(index + 1); - } - } - - private createItem: ListRowRenderer = ({ + private readonly createItem: ListRowRenderer = ({ index, parent, key, @@ -123,16 +125,20 @@ export class ComponentList extends React.Component< rowIndex={index} parent={parent} > -
- - key={this.props.itemLabel(item)} - item={item} - itemRenderer={this.props.itemRenderer} - install={this.props.install} - uninstall={this.props.uninstall} - onFocusDidChange={() => this.clear(index)} - /> -
+ {({ measure, registerChild }) => ( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore +
+ + key={this.props.itemLabel(item)} + item={item} + itemRenderer={this.props.itemRenderer} + install={this.props.install} + uninstall={this.props.uninstall} + onFocusDidChange={() => measure()} + /> +
+ )} ); }; diff --git a/arduino-ide-extension/src/browser/widgets/component-list/filterable-list-container.tsx b/arduino-ide-extension/src/browser/widgets/component-list/filterable-list-container.tsx index 70d4321d2..20b5f317f 100644 --- a/arduino-ide-extension/src/browser/widgets/component-list/filterable-list-container.tsx +++ b/arduino-ide-extension/src/browser/widgets/component-list/filterable-list-container.tsx @@ -51,7 +51,9 @@ export class FilterableListContainer<
{this.renderSearchBar()} {this.renderSearchFilter()} - {this.renderComponentList()} +
+ {this.renderComponentList()} +
); }