Text layout effect always setStates and can exceed React 19 update depth
Bug description
Text (packages/core/src/components/text/text.tsx) always calls setState from its overflow-measuring layout effect, even when the derived title has not changed:
useIsomorphicLayoutEffect(() => {
if (contentMeasuringRef.current?.textContent != null) {
setIsContentOverflowing(
ellipsize! && contentMeasuringRef.current.scrollWidth > contentMeasuringRef.current.clientWidth,
);
setTextContent(contentMeasuringRef.current.textContent);
}
}, [contentMeasuringRef, children, ellipsize]);
children is in the dependency array, so any parent that passes a new element identity (menus with HighlightText / EntityTitle, table cells, etc.) re-runs the effect. Under React 19 that nested update path can exceed the update-depth limit (minified error #185) when many Text nodes measure in one commit.
The effect also ignores an explicit title prop while measuring, then overwrites via title ?? …. Callers that pass title still pay the scrollWidth reflow.
Steps to reproduce
- Use
@blueprintjs/core6.18.0 (also currentdevelop) with React 19. - Render a dense
Menu/EntityTitle/ table whose item labels go throughText ellipsizeand whose children identity changes across parent renders. - The tree crashes with "Maximum update depth exceeded".
Suggested fix
Store a single derived overflow title. Only setState when that string actually changes. If the caller passed title, skip measuring and do not keep an auto title.
Environment
@blueprintjs/core6.18.0 (confirmed ondevelopHEAD)- React 19
Source: palantir/blueprint