1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-24 20:19:10 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
palerdot
2ea412331b Merge remote-tracking branch 'origin/dev' into note-list-display-fix 2023-03-09 12:45:24 +05:30
palerdot
0bf4da3cf5 refactor: logger.warn for ItemList notelist blank space fixes 2023-03-09 11:08:21 +05:30
palerdot
016311a0ae refactor: comments 2023-03-08 20:05:47 +05:30
palerdot
8d592ac1e0 refactor: comments 2023-03-08 19:13:59 +05:30
palerdot
93f4928ea8 Merge remote-tracking branch 'origin/dev' into note-list-display-fix 2023-03-08 19:12:02 +05:30
palerdot
ea855602b9 fix(desktop): handle bottom blank space due to scroll position mismatch 2023-03-08 19:07:50 +05:30
palerdot
45da775649 fix(desktop): handle blank top spacing when toggling note list 2023-03-08 14:48:00 +05:30

View File

@@ -1,4 +1,7 @@
import * as React from 'react';
import Logger from '@joplin/lib/Logger';
const logger = Logger.create('ItemList');
interface Props {
style: any;
@@ -47,6 +50,15 @@ class ItemList extends React.Component<Props, State> {
let bottomItemIndex = topItemIndex + (visibleItemCount - 1);
if (bottomItemIndex >= props.items.length) bottomItemIndex = props.items.length - 1;
// EDGE CASE:
// ref: https://github.com/laurent22/joplin/issues/4124
// when the note list is hidden, visibleItemCount is negative, and scroll top is positive when a note is selected
if (visibleItemCount < 0 && this.scrollTop_ > 0) {
logger.warn('Resetting scrollTop to 0. visibleItemCount is negative, scrollTop is positive.');
// we will reset the scroll top so that there is no blank space at the top of note list
this.scrollTop_ = 0;
}
this.setState({
topItemIndex: topItemIndex,
bottomItemIndex: bottomItemIndex,
@@ -69,6 +81,21 @@ class ItemList extends React.Component<Props, State> {
this.updateStateItemIndexes(newProps);
}
public componentDidUpdate(): void {
// EDGE CASE
// scroll top is not updated when item list visibility is toggled
// if the user was at the bottom of the item list before hiding, blank spaces are added at the bottom of the item list
if (this.offsetScroll() !== this.listRef.current?.scrollTop) {
logger.warn(`scrollTop mismatch. Updating scrollTop with current listRef scrollTop(${this.listRef.current.scrollTop})`);
// update scroll postion once if there is a mismatch in scroll position after showing item list
this.onScroll({
target: {
scrollTop: this.listRef.current.scrollTop,
},
});
}
}
public onScroll(event: any) {
this.scrollTop_ = event.target.scrollTop;
this.updateStateItemIndexes();