Skip to content

Commit 071e8be

Browse files
committed
wip: ensure css prior to calculation
1 parent fbaf9e0 commit 071e8be

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/webui/src/client/ui/util/AdjustLabelFit.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
218218
}
219219

220220
useEffect(() => {
221+
const adjustmentTimer = requestAnimationFrame(() => {
222+
adjustTextToFit()
223+
})
224+
221225
// Add debouncing for resize events
222226
let resizeTimer: number
223227
const handleResize = () => {
@@ -240,6 +244,7 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
240244
window.addEventListener('resize', handleResize)
241245
return () => {
242246
window.removeEventListener('resize', handleResize)
247+
cancelAnimationFrame(adjustmentTimer)
243248
cancelAnimationFrame(resizeTimer)
244249
}
245250
}, [label, width, fontFamily, fontSize, minFontSize, maxFontSize, minLetterSpacing])

0 commit comments

Comments
 (0)