Skip to content

Commit ea1b78e

Browse files
fix(textarea): add hide scrollbar when autosize is true (#3856)
* fix(textarea): add hide scrollbar when autosize is true fix #5567 * chore: update snapshot --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 9b20042 commit ea1b78e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

packages/components/textarea/Textarea.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const Textarea = forwardRef<TextareaRefInterface, TextareaProps>((originalProps,
8888
[`${classPrefix}-is-disabled`]: disabled,
8989
[`${classPrefix}-is-focused`]: isFocused,
9090
[`${classPrefix}-resize-none`]: typeof autosize === 'object',
91+
[`${classPrefix}-hide-scrollbar`]: autosize === true,
9192
});
9293

9394
const adjustTextareaHeight = useEventCallback(() => {

test/snap/__snapshots__/csr.test.jsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135012,7 +135012,7 @@ exports[`csr snapshot test > csr test packages/components/textarea/_example/base
135012135012
class="t-textarea"
135013135013
>
135014135014
<textarea
135015-
class="t-textarea__inner"
135015+
class="t-textarea__inner t-hide-scrollbar"
135016135016
placeholder="请输入内容,高度可自适应,autosize=true"
135017135017
style="height: 0px; min-height: -4px;"
135018135018
/>
@@ -150444,7 +150444,7 @@ exports[`ssr snapshot test > ssr test packages/components/tag-input/_example/sta
150444150444

150445150445
exports[`ssr snapshot test > ssr test packages/components/tag-input/_example/theme.tsx 1`] = `"<div style="width:80%;gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--primary t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--primary t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--primary t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--success t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--success t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--success t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--warning t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--warning t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--warning t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--danger t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--danger t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--danger t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div></div>"`;
150446150446

150447-
exports[`ssr snapshot test > ssr test packages/components/textarea/_example/base.tsx 1`] = `"<div style="width:100%;gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容" rows="2" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,autosize=true" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,最少3行,最多10行,超过会出滚动条" style="height:auto;min-height:auto" class="t-textarea__inner t-resize-none"></textarea></div></div></div>"`;
150447+
exports[`ssr snapshot test > ssr test packages/components/textarea/_example/base.tsx 1`] = `"<div style="width:100%;gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容" rows="2" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,autosize=true" style="height:auto;min-height:auto" class="t-textarea__inner t-hide-scrollbar"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,最少3行,最多10行,超过会出滚动条" style="height:auto;min-height:auto" class="t-textarea__inner t-resize-none"></textarea></div></div></div>"`;
150448150448

150449150449
exports[`ssr snapshot test > ssr test packages/components/textarea/_example/events.tsx 1`] = `"<div class="t-textarea"><textarea placeholder="请输入内容" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div>"`;
150450150450

test/snap/__snapshots__/ssr.test.jsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ exports[`ssr snapshot test > ssr test packages/components/tag-input/_example/sta
11121112

11131113
exports[`ssr snapshot test > ssr test packages/components/tag-input/_example/theme.tsx 1`] = `"<div style="width:80%;gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--primary t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--primary t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--primary t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--success t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--success t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--success t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--warning t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--warning t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--warning t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div><div class="t-space-item"><div class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input--with-tag" value="" spellcheck="false"><div class="t-input t-align-left t-input--prefix"><div class="t-input__prefix"><div class="t-tag t-tag--danger t-tag--dark"><span title="Vue">Vue</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--danger t-tag--dark"><span title="React">React</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div><div class="t-tag t-tag--danger t-tag--dark"><span title="Miniprogram">Miniprogram</span><svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-close t-tag__icon-close" style="fill:none"><g id="close"><path id="stroke1" stroke="currentColor" d="M16.9503 7.05029L12.0005 12M12.0005 12L7.05078 16.9498M12.0005 12L16.9503 16.9498M12.0005 12L7.05078 7.05029" stroke-linecap="square" stroke-width="2"></path></g></svg></div></div><input placeholder="" type="text" class="t-input__inner" value=""/><span class="t-input__input-pre"></span></div></div></div></div>"`;
11141114

1115-
exports[`ssr snapshot test > ssr test packages/components/textarea/_example/base.tsx 1`] = `"<div style="width:100%;gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容" rows="2" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,autosize=true" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,最少3行,最多10行,超过会出滚动条" style="height:auto;min-height:auto" class="t-textarea__inner t-resize-none"></textarea></div></div></div>"`;
1115+
exports[`ssr snapshot test > ssr test packages/components/textarea/_example/base.tsx 1`] = `"<div style="width:100%;gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容" rows="2" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,autosize=true" style="height:auto;min-height:auto" class="t-textarea__inner t-hide-scrollbar"></textarea></div></div><div class="t-space-item"><div class="t-textarea"><textarea placeholder="请输入内容,高度可自适应,最少3行,最多10行,超过会出滚动条" style="height:auto;min-height:auto" class="t-textarea__inner t-resize-none"></textarea></div></div></div>"`;
11161116

11171117
exports[`ssr snapshot test > ssr test packages/components/textarea/_example/events.tsx 1`] = `"<div class="t-textarea"><textarea placeholder="请输入内容" style="height:auto;min-height:auto" class="t-textarea__inner"></textarea></div>"`;
11181118

0 commit comments

Comments
 (0)