Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: message box issues #27495

Merged
merged 3 commits into from Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions apps/meteor/app/ui-message/client/messageBox/messageBox.ts
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -351,7 +352,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);
});
});
});
Expand Down
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/ui-utils/client/lib/readMessages.ts
Expand Up @@ -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');
}
}
}
Expand Down