From 3b87d33e204f8c37241a6c60a4c6527f75fdc5cf Mon Sep 17 00:00:00 2001 From: Anastasia <155824290+kryzanivska-nastya@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:04:03 +0200 Subject: [PATCH 1/3] fixed --- .../comment-textarea.component.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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..f42c5a84f1 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); From e052cb6d83a87a2ebdc5e11fcbf29d5ec4bc3daf Mon Sep 17 00:00:00 2001 From: Anastasia <155824290+kryzanivska-nastya@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:15:07 +0200 Subject: [PATCH 2/3] Handle null or unexpected values --- .../components/comment-textarea/comment-textarea.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f42c5a84f1..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 @@ -266,7 +266,7 @@ export class CommentTextareaComponent implements OnInit, AfterViewInit, OnChange } private clearPlaceholderIfNeeded(): void { - const currentText = this.commentTextarea.nativeElement.textContent.trim(); + const currentText = this.commentTextarea?.nativeElement?.textContent?.trim() || ''; if (this.isPlaceholderText(currentText)) { this.commentTextarea.nativeElement.textContent = ''; this.content.setValue(''); From 4d1dd97bcd182d1e4039b3443d81aad5207b1e60 Mon Sep 17 00:00:00 2001 From: Anastasia <155824290+kryzanivska-nastya@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:15:52 +0200 Subject: [PATCH 3/3] fix style #7775 --- .../components/comment-textarea/comment-textarea.component.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;