Skip to content

Commit

Permalink
Should also compare prev & next events for clientHeight & `clientWi…
Browse files Browse the repository at this point in the history
…dth` as they might also change
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Jun 7, 2022
1 parent e0cd678 commit 324fa64
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/Scrollable/Scrollable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ export default class Scrollable extends React.PureComponent {

const nextEvent = this.event.next,
prevEvent = this.event.prev,
changed = nextEvent.scrollHeight !== prevEvent.scrollHeight ||
changed = nextEvent.clientHeight !== prevEvent.clientHeight ||
nextEvent.scrollHeight !== prevEvent.scrollHeight ||
nextEvent.clientWidth !== prevEvent.clientWidth ||
nextEvent.scrollWidth !== prevEvent.scrollWidth ||
nextEvent.top !== prevEvent.top ||
nextEvent.left !== prevEvent.left;
Expand Down Expand Up @@ -167,14 +169,16 @@ export default class Scrollable extends React.PureComponent {
};

render() {
const {children, element, className} = this.props;
// (props should not contain ilegal HTML attributes)
// eslint-disable-next-line no-unused-vars
const {children, element, className, cssVarsOnTracks, scrollOnDOMChange, onUpdate, ...props} = this.props;
const vsb = findChildByType(children, VerticalScrollbarPlaceholder);
const hsb = findChildByType(children, HorizontalScrollbarPlaceholder);
const content = React.Children.toArray(children).filter(child => ![VerticalScrollbarPlaceholder, HorizontalScrollbarPlaceholder].includes(child.type));

return (
<ResizeObserver onResize={this.updateScrollbars}>
<div {...this.props} className={classNames('scrollable', className)} onTransitionEnd={this.handleOnTransitionEnd}>
<div {...props} className={classNames('scrollable', className)} onTransitionEnd={this.handleOnTransitionEnd}>
{React.cloneElement(element, this.getElementProps(), content)}
<Context.Provider value={this.state}>
{vsb ? vsb.props.children : <VerticalScrollbar/>}
Expand Down

0 comments on commit 324fa64

Please sign in to comment.