mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-29 21:21:15 +02:00
This commit is contained in:
parent
27ef917350
commit
fb9e78d6c1
@ -55,7 +55,7 @@ const NoteListComponent = (props: Props) => {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const itemHeight = 34;
|
const [itemHeight, setItemHeight] = useState(34);
|
||||||
|
|
||||||
const focusItemIID_ = useRef<any>(null);
|
const focusItemIID_ = useRef<any>(null);
|
||||||
const noteListRef = useRef(null);
|
const noteListRef = useRef(null);
|
||||||
@ -453,6 +453,16 @@ const NoteListComponent = (props: Props) => {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// When a note list item is styled by userchrome.css, its height is reflected.
|
||||||
|
// Ref. https://github.com/laurent22/joplin/pull/6542
|
||||||
|
const noteItem = Object.values<any>(itemAnchorRefs_.current)[0]?.current;
|
||||||
|
const actualItemHeight = noteItem?.getHeight() ?? 0;
|
||||||
|
if (actualItemHeight >= 8) { // To avoid generating too many narrow items
|
||||||
|
setItemHeight(actualItemHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const renderEmptyList = () => {
|
const renderEmptyList = () => {
|
||||||
if (props.notes.length) return null;
|
if (props.notes.length) return null;
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ function NoteListItem(props: NoteListItemProps, ref: any) {
|
|||||||
focus: function() {
|
focus: function() {
|
||||||
if (anchorRef.current) anchorRef.current.focus();
|
if (anchorRef.current) anchorRef.current.focus();
|
||||||
},
|
},
|
||||||
|
getHeight: () => anchorRef.current?.clientHeight,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user