From c36ac70ede56b21459ebfd21d9f07e5efee9aec5 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Thu, 8 Dec 2022 11:54:45 -0300 Subject: [PATCH 1/3] Fix autogrow --- apps/meteor/app/ui-message/client/messageBox/messageBox.ts | 2 +- .../app/ui-message/client/messageBox/messageBoxAutogrow.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/meteor/app/ui-message/client/messageBox/messageBox.ts b/apps/meteor/app/ui-message/client/messageBox/messageBox.ts index 6453dfd564d7..349bbf0e9082 100644 --- a/apps/meteor/app/ui-message/client/messageBox/messageBox.ts +++ b/apps/meteor/app/ui-message/client/messageBox/messageBox.ts @@ -351,7 +351,7 @@ Template.messageBox.onRendered(function (this: MessageBoxTemplateInstance) { } const shadow = this.find('.js-input-message-shadow'); - this.autogrow = onResize ? setupAutogrow(input, shadow, onResize) : null; + this.autogrow = setupAutogrow(input, shadow, onResize); }); }); }); diff --git a/apps/meteor/app/ui-message/client/messageBox/messageBoxAutogrow.ts b/apps/meteor/app/ui-message/client/messageBox/messageBoxAutogrow.ts index 192c92933f56..c8194f48abcd 100644 --- a/apps/meteor/app/ui-message/client/messageBox/messageBoxAutogrow.ts +++ b/apps/meteor/app/ui-message/client/messageBox/messageBoxAutogrow.ts @@ -2,7 +2,7 @@ import _ from 'underscore'; const replaceWhitespaces = (whitespaces: string) => `${' '.repeat(whitespaces.length - 1)} `; -export const setupAutogrow = (textarea: HTMLTextAreaElement, shadow: HTMLElement, callback: () => void) => { +export const setupAutogrow = (textarea: HTMLTextAreaElement, shadow: HTMLElement, callback: (() => void) | undefined) => { const width = textarea.clientWidth; const height = textarea.clientHeight; const { font, lineHeight, maxHeight: maxHeightPx } = window.getComputedStyle(textarea); From 9789121b798735542faa2324aa1f74c5b21f10d3 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Thu, 8 Dec 2022 12:15:28 -0300 Subject: [PATCH 2/3] Fix persistence --- .../app/ui-message/client/messageBox/messageBox.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/meteor/app/ui-message/client/messageBox/messageBox.ts b/apps/meteor/app/ui-message/client/messageBox/messageBox.ts index 349bbf0e9082..1fc8a3f7575b 100644 --- a/apps/meteor/app/ui-message/client/messageBox/messageBox.ts +++ b/apps/meteor/app/ui-message/client/messageBox/messageBox.ts @@ -209,13 +209,12 @@ Template.messageBox.onCreated(function (this: MessageBoxTemplateInstance) { this.isSendIconVisible = new ReactiveVar(false); this.set = (value) => { - const { input } = this; - if (!input) { + if (!this.input) { return; } - input.value = value; - $(input).trigger('change').trigger('input'); + this.input.value = value; + $(this.input).trigger('change').trigger('input'); }; this.insertNewLine = () => { @@ -315,8 +314,10 @@ Template.messageBox.onRendered(function (this: MessageBoxTemplateInstance) { this.input = input; if (chatContext) { - const storageID = `${rid}${tmid ? `-${tmid}` : ''}`; - chatContext.setComposerAPI(createComposerAPI(input, storageID)); + const storageID = `messagebox_${rid}${tmid ? `-${tmid}` : ''}`; + const composer = createComposerAPI(input, storageID); + chatContext.setComposerAPI(composer); + this.set = composer.setText; } setTimeout(() => { From 0d62855d586e79fd52a9c98fcfe535994400a4cc Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Thu, 8 Dec 2022 12:36:14 -0300 Subject: [PATCH 3/3] Fix `readMessages` --- apps/meteor/app/ui-utils/client/lib/readMessages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/app/ui-utils/client/lib/readMessages.ts b/apps/meteor/app/ui-utils/client/lib/readMessages.ts index d36a76d90866..b6a90fcf4758 100644 --- a/apps/meteor/app/ui-utils/client/lib/readMessages.ts +++ b/apps/meteor/app/ui-utils/client/lib/readMessages.ts @@ -160,7 +160,7 @@ export class ReadMessage extends Emitter { if (firstUnreadRecord) { room.unreadFirstId = firstUnreadRecord._id; document.querySelector('.message.first-unread')?.classList.remove('first-unread'); - document.querySelector(`.message#${firstUnreadRecord._id}`)?.classList.add('first-unread'); + document.querySelector(`.message[data-id="${firstUnreadRecord._id}"]`)?.classList.add('first-unread'); } } }