diff --git a/src/components/manga/MangaDetails.tsx b/src/components/manga/MangaDetails.tsx index 8c728579f1..1a7550a6cf 100644 --- a/src/components/manga/MangaDetails.tsx +++ b/src/components/manga/MangaDetails.tsx @@ -186,9 +186,18 @@ const DescriptionGenre = ({ }: { manga: Pick; }) => { + const [descriptionElement, setDescriptionElement] = useState(null); + const [descriptionHeight, setDescriptionHeight] = useState(); + useResizeObserver( + descriptionElement, + useCallback(() => setDescriptionHeight(descriptionElement?.clientHeight), [descriptionElement]), + ); + const [isCollapsed, setIsCollapsed] = useLocalStorage('isDescriptionGenreCollapsed', true); - const collapsedSize = description ? DESCRIPTION_COLLAPSED_SIZE : 0; + const collapsedSize = description + ? Math.min(DESCRIPTION_COLLAPSED_SIZE, descriptionHeight ?? DESCRIPTION_COLLAPSED_SIZE) + : 0; const genres = useMemo(() => mangaGenres.filter(Boolean), [mangaGenres]); return ( @@ -196,7 +205,10 @@ const DescriptionGenre = ({ {description && ( - + {description}