mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(site): add resize observer to session timeline expandable text (#24119)
I said I wouldn't but the illustrious @jakehwll added a ResizeObserver recently so imma do that too. This makes `<ExpandableText>` determine if it should be expandable or not on resize
This commit is contained in:
@@ -48,7 +48,18 @@ const ExpandableText: FC<ExpandableTextProps> = ({
|
||||
useEffect(() => {
|
||||
const el = contentRef.current;
|
||||
if (!el) return;
|
||||
setIsExpandable(el.scrollHeight > maxHeight);
|
||||
|
||||
const checkIsExpandable = () => {
|
||||
setIsExpandable(el.scrollHeight > maxHeight);
|
||||
};
|
||||
|
||||
checkIsExpandable();
|
||||
|
||||
const observer = new ResizeObserver(checkIsExpandable);
|
||||
|
||||
observer.observe(el);
|
||||
|
||||
return () => observer.disconnect();
|
||||
}, [maxHeight]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user