xugenyuan

ref |> 解决评论输入框默认弹起键盘问题

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -17,8 +17,6 @@ export struct CommentCustomDialog {
@State positionInfo: CaretOffset = { index: 0, x: 0, y: 0 }
aboutToAppear(): void {
// this.textInputController.caretPosition(0)
}
publishCommentRequest() {
... ... @@ -51,12 +49,20 @@ export struct CommentCustomDialog {
controller: this.textInputController,
text: this.publishCommentModel.commentContent
})
.id("textAreaId")
.defaultFocus(true) // 获取默认焦点
.enableKeyboardOnFocus(true)
.height('100%')
.width('100%')
.backgroundColor($r('app.color.color_transparent'))
.onChange(value => {
this.publishCommentModel.commentContent = value;
})
.onFocus(() => {
if (this.emojiSwitch) {
this.emojiSwitch = false
}
})
}
.backgroundColor('#F9F9F9')
// .width('100%')
... ... @@ -81,6 +87,7 @@ export struct CommentCustomDialog {
if (this.emojiSwitch) {
this.textInputController.stopEditing()
} else {
focusControl.requestFocus("textAreaId") // 弹起键盘
// this.textInputController.caretPosition(this.textInputController.getTextContentRect().x)
}
... ...