Skip to content

Commit 2f9df36

Browse files
committed
修复备注文本框的标签重复显示问题
1 parent 14ff9c0 commit 2f9df36

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/config/ui/component/basic/textarea/textarea-component.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class TextareaComponent implements LanguageUpdateable {
2828
* @param onChange 值变更回调
2929
* @param maxLength 最大长度限制
3030
* @param showCounter 是否显示计数器
31+
* @param showLabel 是否显示标签,默认为false
3132
*/
3233
constructor(
3334
id: string,
@@ -36,7 +37,8 @@ export class TextareaComponent implements LanguageUpdateable {
3637
value: string,
3738
onChange: (value: string) => void,
3839
maxLength?: number,
39-
showCounter: boolean = true
40+
showCounter: boolean = true,
41+
showLabel: boolean = false
4042
) {
4143
this.componentId = `textarea-${id}-${Math.floor(Math.random() * 1000000)}`;
4244
this.currentLabel = name;
@@ -52,7 +54,7 @@ export class TextareaComponent implements LanguageUpdateable {
5254
this.containerElement.className = 'js-script-hook-textarea-container';
5355
this.containerElement.id = this.componentId;
5456

55-
this.render(value, onChange);
57+
this.render(value, onChange, showLabel);
5658

5759
// 订阅语言更新事件
5860
LanguageEventManager.getInstance().subscribe(this.componentId, (language: Language) => {
@@ -78,13 +80,16 @@ export class TextareaComponent implements LanguageUpdateable {
7880
* 渲染组件
7981
* @param value 初始值
8082
* @param onChange 值变更回调
83+
* @param showLabel 是否显示标签
8184
*/
82-
private render(value: string, onChange: (value: string) => void): void {
85+
private render(value: string, onChange: (value: string) => void, showLabel: boolean): void {
8386
// 创建标签
84-
const label = document.createElement('label');
85-
label.className = 'js-script-hook-textarea-label';
86-
label.textContent = this.currentLabel;
87-
this.containerElement.appendChild(label);
87+
if (showLabel) {
88+
const label = document.createElement('label');
89+
label.className = 'js-script-hook-textarea-label';
90+
label.textContent = this.currentLabel;
91+
this.containerElement.appendChild(label);
92+
}
8893

8994
// 创建文本域
9095
this.textareaElement = document.createElement('textarea');

src/config/ui/component/debugger/events.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ export function bindDebuggerEvents(
255255
}
256256
},
257257
undefined,
258-
true
258+
true,
259+
false // 不显示标签,因为表格行已经有标签
259260
);
260261
commentContainer.appendChild(commentTextarea.getDomElement());
261262
}

0 commit comments

Comments
 (0)