Possible fix for weird truncation bug

This commit is contained in:
Lim Chee Aun 2023-03-16 16:16:15 +08:00
parent bc4dfaf62f
commit 16c52ad3ea

View file

@ -211,11 +211,15 @@ function Status({
onResize: () => { onResize: () => {
if (spoilerContentRef.current) { if (spoilerContentRef.current) {
const { scrollHeight, clientHeight } = spoilerContentRef.current; const { scrollHeight, clientHeight } = spoilerContentRef.current;
if (scrollHeight < window.innerHeight * 0.4) {
spoilerContentRef.current.classList.remove('truncated');
} else {
spoilerContentRef.current.classList.toggle( spoilerContentRef.current.classList.toggle(
'truncated', 'truncated',
scrollHeight > clientHeight, scrollHeight > clientHeight,
); );
} }
}
}, },
}); });
const contentRef = useRef(null); const contentRef = useRef(null);
@ -224,11 +228,15 @@ function Status({
onResize: () => { onResize: () => {
if (contentRef.current) { if (contentRef.current) {
const { scrollHeight, clientHeight } = contentRef.current; const { scrollHeight, clientHeight } = contentRef.current;
if (scrollHeight < window.innerHeight * 0.4) {
contentRef.current.classList.remove('truncated');
} else {
contentRef.current.classList.toggle( contentRef.current.classList.toggle(
'truncated', 'truncated',
scrollHeight > clientHeight, scrollHeight > clientHeight,
); );
} }
}
}, },
}); });
const readMoreText = 'Read more →'; const readMoreText = 'Read more →';