Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: ensure focus and send button in editing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorvargasdev committed Apr 3, 2024
1 parent 53d188f commit 2c0fcae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/web-components/comments/components/comment-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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;

Expand All @@ -36,6 +39,7 @@ export class CommentsCommentInput extends WebComponentsBaseElement {
this.text = '';
this.mentionList = [];
this.mentions = [];
this.mode = CommentMode.READONLY;
}

static styles = styles;
Expand All @@ -50,6 +54,7 @@ export class CommentsCommentInput extends WebComponentsBaseElement {
mentionList: { type: Object },
participantsList: { type: Object },
hideInput: { type: Boolean },
mode: { type: String },
};

private addAtSymbolInCaretPosition = () => {
Expand Down Expand Up @@ -139,6 +144,13 @@ export class CommentsCommentInput extends WebComponentsBaseElement {
}

updated(changedProperties: Map<string, any>) {
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;
Expand Down
1 change: 1 addition & 0 deletions src/web-components/comments/components/comment-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export class CommentsCommentItem extends WebComponentsBaseElement {
<superviz-comments-comment-input
class="${classMap(classes)}"
editable
mode=${this.mode}
@click=${(event: Event) => event.stopPropagation()}
text=${this.text}
eventType="update-comment"
Expand Down

0 comments on commit 2c0fcae

Please sign in to comment.