Skip to content

Commit

Permalink
[core] fix(Text): use isomorphic layout effect (#6687)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Jan 31, 2024
1 parent cbb705c commit 956bf16
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/components/text/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as React from "react";

import { Classes, mergeRefs } from "../../common";
import { DISPLAYNAME_PREFIX, type Props } from "../../common/props";
import { useIsomorphicLayoutEffect } from "../../hooks/useIsomorphicLayoutEffect";

export interface TextProps
extends Props,
Expand Down Expand Up @@ -61,7 +62,7 @@ export const Text: React.FC<TextProps> = React.forwardRef<HTMLElement, TextProps

// try to be conservative about running this effect, since querying scrollWidth causes the browser to reflow / recalculate styles,
// which can be very expensive for long lists (for example, in long Menus)
React.useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
if (contentMeasuringRef.current?.textContent != null) {
setIsContentOverflowing(
ellipsize! && contentMeasuringRef.current.scrollWidth > contentMeasuringRef.current.clientWidth,
Expand Down

1 comment on commit 956bf16

@adidahiya
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[core] fix(Text): use isomorphic layout effect (#6687)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.