Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Fixes #5178: NoteListItem's height can be properly styled using CSS for v2.8+ #6542

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/app-desktop/gui/NoteList/NoteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const NoteListComponent = (props: Props) => {
};
}, []);

const itemHeight = 34;
const [itemHeight, setItemHeight] = useState(34);

const focusItemIID_ = useRef<any>(null);
const noteListRef = useRef(null);
Expand Down Expand Up @@ -453,6 +453,14 @@ const NoteListComponent = (props: Props) => {
};
}, []);

useEffect(() => {
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);
}
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to explain why this is needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


const renderEmptyList = () => {
if (props.notes.length) return null;

Expand Down
1 change: 1 addition & 0 deletions packages/app-desktop/gui/NoteListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function NoteListItem(props: NoteListItemProps, ref: any) {
focus: function() {
if (anchorRef.current) anchorRef.current.focus();
},
getHeight: () => anchorRef.current?.clientHeight,
};
});

Expand Down