From 712a443ccdc6d8cf29d68a41d6590122628c1514 Mon Sep 17 00:00:00 2001
From: Kayokoi <113896798+wozhenbang2004@users.noreply.github.com>
Date: Thu, 12 Nov 2026 12:32:38 +0800
Subject: [PATCH 1/2] fix: account for word-spacing in TextArea autoSize
---
src/calculateNodeHeight.tsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/calculateNodeHeight.tsx b/src/calculateNodeHeight.tsx
index e16c9fd..e60d115 100644
--- a/src/calculateNodeHeight.tsx
+++ b/src/calculateNodeHeight.tsx
@@ -20,6 +20,7 @@ const HIDDEN_TEXTAREA_STYLE = `
const SIZING_STYLE = [
'letter-spacing',
+ 'word-spacing',
'line-height',
'padding-top',
'padding-bottom',
From 46a201b3014a76bbdfe0a6f5f0ad5975d88563a5 Mon Sep 17 00:00:00 2001
From: Kayokoi <113896798+wozhenbang2004@users.noreply.github.com>
Date: Thu, 12 Nov 2026 12:34:20 +0800
Subject: [PATCH 2/2] test: cover word spacing in TextArea autoSize
---
tests/TextArea.test.tsx | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/tests/TextArea.test.tsx b/tests/TextArea.test.tsx
index 390f1cd..aa64162 100644
--- a/tests/TextArea.test.tsx
+++ b/tests/TextArea.test.tsx
@@ -196,10 +196,27 @@ describe('TextArea', () => {
boxSizing: 'border-box',
paddingSize: 4,
sizingStyle:
- 'letter-spacing:normal;line-height:normal;padding-top:2px;padding-bottom:2px;font-family:-webkit-small-control;font-weight:;font-size:;font-variant:;text-rendering:auto;text-transform:none;width:;text-indent:0;padding-left:2px;padding-right:2px;border-width:1px;box-sizing:border-box;word-break:;white-space:pre-wrap',
+ 'letter-spacing:normal;word-spacing:normal;line-height:normal;padding-top:2px;padding-bottom:2px;font-family:-webkit-small-control;font-weight:;font-size:;font-variant:;text-rendering:auto;text-transform:none;width:;text-indent:0;padding-left:2px;padding-right:2px;border-width:1px;box-sizing:border-box;word-break:;white-space:pre-wrap',
});
});
+ it.each(['8px', '16px', '-2px', 'normal'])(
+ 'copies word-spacing %s when measuring autoSize',
+ (wordSpacing) => {
+ render(
+ ,
+ );
+ const measurement = document.querySelector(
+ 'textarea[aria-hidden="true"]',
+ );
+ expect(measurement).toHaveStyle({ wordSpacing });
+ },
+ );
+
it('boxSizing === "border-box"', () => {
const wrapper = document.createElement('textarea');
wrapper.style.boxSizing = 'border-box';