From 2c0fcaebe6914dbd86d425e73639eabec51f5317 Mon Sep 17 00:00:00 2001 From: vitorvargasdev Date: Wed, 3 Apr 2024 09:49:31 -0300 Subject: [PATCH] fix: ensure focus and send button in editing mode --- .../comments/components/comment-input.ts | 12 ++++++++++++ .../comments/components/comment-item.ts | 1 + 2 files changed, 13 insertions(+) diff --git a/src/web-components/comments/components/comment-input.ts b/src/web-components/comments/components/comment-input.ts index 38284d60..e1aea337 100644 --- a/src/web-components/comments/components/comment-input.ts +++ b/src/web-components/comments/components/comment-input.ts @@ -10,6 +10,8 @@ import { commentInputStyle } from '../css'; import { AutoCompleteHandler } from '../utils/autocomplete-handler'; import mentionHandler from '../utils/mention-handler'; +import { CommentMode } from './types'; + const WebComponentsBaseElement = WebComponentsBase(LitElement); const styles: CSSResultGroup[] = [WebComponentsBaseElement.styles, commentInputStyle]; @@ -25,6 +27,7 @@ export class CommentsCommentInput extends WebComponentsBaseElement { declare mentions: CommentMention[]; declare participantsList: ParticipantByGroupApi[]; declare hideInput: boolean; + declare mode: CommentMode; private pinCoordinates: AnnotationPositionInfo | null = null; @@ -36,6 +39,7 @@ export class CommentsCommentInput extends WebComponentsBaseElement { this.text = ''; this.mentionList = []; this.mentions = []; + this.mode = CommentMode.READONLY; } static styles = styles; @@ -50,6 +54,7 @@ export class CommentsCommentInput extends WebComponentsBaseElement { mentionList: { type: Object }, participantsList: { type: Object }, hideInput: { type: Boolean }, + mode: { type: String }, }; private addAtSymbolInCaretPosition = () => { @@ -139,6 +144,13 @@ export class CommentsCommentInput extends WebComponentsBaseElement { } updated(changedProperties: Map) { + if (changedProperties.has('mode') && this.mode === CommentMode.EDITABLE) { + this.focusInput() + this.updateHeight(); + this.sendBtn.disabled = false; + this.btnActive = true; + } + if (changedProperties.has('text') && this.text.length > 0) { const commentsInput = this.commentInput; commentsInput.value = this.text; diff --git a/src/web-components/comments/components/comment-item.ts b/src/web-components/comments/components/comment-item.ts index e93b7524..5a7f58f7 100644 --- a/src/web-components/comments/components/comment-item.ts +++ b/src/web-components/comments/components/comment-item.ts @@ -175,6 +175,7 @@ export class CommentsCommentItem extends WebComponentsBaseElement { event.stopPropagation()} text=${this.text} eventType="update-comment"