-
-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix virtualization (windowing) when displaying options with long titl…
…es for select widgets (#3661) * WIP * First working implementation * Add react-virtualized as a Loadable * Changelog * Improve components, add CSS for breaking long words * Remove useDimensions hook, since we are not using in this one. * Increase a bit the maxSize for bundle watch * Remove as a dependency
- Loading branch information
Showing
9 changed files
with
120 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/components/manage/ReactVirtualized/DynamicRowHeightList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable'; | ||
|
||
class DynamicHeightList extends React.PureComponent { | ||
// As per `react-virtualized` docs, one should use a PureComponent | ||
// to avoid performance issues | ||
// We could have used a React.memo + functional component instead, | ||
// but relied on the class-based implementation for simplicity | ||
constructor(props) { | ||
super(props); | ||
|
||
this._cache = new props.reactVirtualized.CellMeasurerCache({ | ||
fixedWidth: true, | ||
minHeight: 50, | ||
}); | ||
|
||
this._rowRenderer = this._rowRenderer.bind(this); | ||
} | ||
|
||
_rowRenderer({ index, key, parent, style }) { | ||
const CellMeasurer = this.props.reactVirtualized.CellMeasurer; | ||
return ( | ||
<CellMeasurer | ||
cache={this._cache} | ||
columnIndex={0} | ||
key={key} | ||
rowIndex={index} | ||
parent={parent} | ||
> | ||
{({ measure }) => <div style={style}>{this.props.children[index]}</div>} | ||
</CellMeasurer> | ||
); | ||
} | ||
|
||
render() { | ||
const List = this.props.reactVirtualized.List; | ||
|
||
return ( | ||
<List | ||
{...this.props} | ||
ref={(element) => { | ||
this._list = element; | ||
}} | ||
deferredMeasurementCache={this._cache} | ||
overscanRowCount={0} | ||
rowCount={this.props.children.length} | ||
rowHeight={this._cache.rowHeight} | ||
rowRenderer={this._rowRenderer} | ||
width={200} | ||
height={500} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default injectLazyLibs('reactVirtualized')(DynamicHeightList); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters