diff --git a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss index 61b597a5ef..5fd8e1445a 100644 --- a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss +++ b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.scss @@ -12,7 +12,7 @@ .comment-textarea-uploader { position: relative; - width: 100%; + width: calc(100% - 1px); .cancel-btn { font-size: 18px; diff --git a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts index eb70b4868e..6823fffdf2 100644 --- a/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts +++ b/src/app/main/component/comments/components/comment-textarea/comment-textarea.component.ts @@ -196,11 +196,7 @@ export class CommentTextareaComponent implements OnInit, AfterViewInit, OnChange } onCommentTextareaFocus(): void { - const currentText = this.commentTextarea.nativeElement.textContent.trim(); - if (currentText === 'Add a comment' || currentText === '') { - this.commentTextarea.nativeElement.textContent = ''; - } - + this.clearPlaceholderIfNeeded(); const range = document.createRange(); const nodeAmount = this.commentTextarea.nativeElement.childNodes.length; range.setStartAfter(this.commentTextarea.nativeElement.childNodes[nodeAmount - 1]); @@ -246,6 +242,8 @@ export class CommentTextareaComponent implements OnInit, AfterViewInit, OnChange file: fileHandle.file }); } + + this.clearPlaceholderIfNeeded(); this.isImageUploaderOpen = false; this.showImageControls = true; this.emitComment(); @@ -267,6 +265,18 @@ export class CommentTextareaComponent implements OnInit, AfterViewInit, OnChange }); } + private clearPlaceholderIfNeeded(): void { + const currentText = this.commentTextarea?.nativeElement?.textContent?.trim() || ''; + if (this.isPlaceholderText(currentText)) { + this.commentTextarea.nativeElement.textContent = ''; + this.content.setValue(''); + } + } + + private isPlaceholderText(text: string): boolean { + return text === 'Add a comment' || text === ''; + } + private insertTextAtCursor(text: string): void { const selection = window.getSelection(); const range = selection.getRangeAt(0);