Skip to content

Commit db846be

Browse files
authored
fix(tinyTag): via getComputedTextLength api to measure svg text element (#636)
1 parent b36ab2e commit db846be

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/tinyTag/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const useSvgWidth = (): UseSvgWidthResult => {
1818
const getWidth = useCallback(() => {
1919
if (!element) return;
2020
const paddingWidth = 8;
21-
const textWidth = Math.round(element.getBoundingClientRect()?.width);
21+
const textWidth = Math.round(element.getComputedTextLength?.() ?? 0);
2222
const svgWidth = textWidth + paddingWidth;
2323
setSvgWidth(svgWidth);
2424
setRectWidth(Math.max(svgWidth - 1, 0));

0 commit comments

Comments
 (0)