fix: re-attach ResizeObserver when overflow element switches DOM nodes
Add isOverflowing to the useEffect dependency array so the ResizeObserver is re-created when the component switches between the <p> and <button> elements, preventing the observer from staying attached to a detached DOM node. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
53736585dc
commit
37530a4da1
@@ -41,7 +41,7 @@ function OverflowDescription({ text }: { text: string }) {
|
||||
observer.observe(ref.current);
|
||||
}
|
||||
return () => observer.disconnect();
|
||||
}, [checkOverflow, text]);
|
||||
}, [checkOverflow, text, isOverflowing]);
|
||||
|
||||
if (isOverflowing) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user