Debounce read marker update on scroll

Reverts https://github.com/matrix-org/matrix-react-sdk/pull/6751 in
favour of debouncing the updates to read markers, because it seems
allowing the scroll to be 1px away from the bottom was important for
some browsers and meant they never got to the bottom.

We can fix the problem instead by debouncing the update to read
markers, because the scroll state gets reset back to the bottom when
componentDidUpdate() runs which happens after the read marker code
does a setState(). This should probably be debounced anyway since
it doesn't need to be run that frequently.

Fixes https://github.com/vector-im/element-web/issues/18961
Type: bugfix
This commit is contained in:
David Baker 2021-09-09 15:58:19 +01:00
parent 8cf891f9a4
commit a4aa6dfcd7
2 changed files with 30 additions and 14 deletions

View file

@ -276,7 +276,7 @@ export default class ScrollPanel extends React.Component<IProps> {
// for scrollTop happen on certain browsers/platforms
// when scrolled all the way down. E.g. Chrome 72 on debian.
// so check difference < 1;
return Math.abs(sn.scrollHeight - (sn.scrollTop + sn.clientHeight)) < 1;
return Math.abs(sn.scrollHeight - (sn.scrollTop + sn.clientHeight)) <= 1;
};
// returns the vertical height in the given direction that can be removed from