From 16a821645f8d9824a92c67386064a55c0c3296e7 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 15 Jan 2019 09:42:55 -0800 Subject: [PATCH] Preserve scroll position on toggle emoji panel, add attachment --- js/views/conversation_view.js | 12 ++++++------ js/views/file_input_view.js | 4 +--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index c719e18ee8d9..c009abb28c80 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -151,16 +151,15 @@ this.fileInput = new Whisper.FileInputView({ el: this.$('.attachment-list'), }); - this.listenTo( - this.fileInput, - 'attachments-changed', - this.toggleMicrophone - ); this.listenTo( this.fileInput, 'choose-attachment', this.onChooseAttachment ); + this.listenTo(this.fileInput, 'staged-attachments-changed', () => { + this.view.resetScrollPosition(); + this.toggleMicrophone(); + }); const getHeaderProps = () => { const expireTimer = this.model.get('expireTimer'); @@ -1485,7 +1484,6 @@ if (event.key !== 'Escape') { return; } - this.closeEmojiPanel(); }, openEmojiPanel() { @@ -1493,6 +1491,7 @@ this.emojiPanel = new EmojiPanel(this.$emojiPanelContainer[0], { onClick: this.insertEmoji.bind(this), }); + this.view.resetScrollPosition(); this.updateMessageFieldSize({}); }, closeEmojiPanel() { @@ -1502,6 +1501,7 @@ this.$emojiPanelContainer.empty().outerHeight(0); this.emojiPanel = null; + this.view.resetScrollPosition(); this.updateMessageFieldSize({}); }, insertEmoji(e) { diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js index dcd46c7684c7..cebca04c7524 100644 --- a/js/views/file_input_view.js +++ b/js/views/file_input_view.js @@ -72,6 +72,7 @@ render() { this.attachmentListView.update(this.getPropsForAttachmentList()); + this.trigger('staged-attachments-changed'); }, getPropsForAttachmentList() { @@ -120,7 +121,6 @@ onCloseAttachment(attachment) { this.attachments = _.without(this.attachments, attachment); - this.trigger('attachments-changed'); this.render(); }, @@ -130,7 +130,6 @@ onClose() { this.attachments = []; - this.trigger('attachments-changed'); this.render(); }, @@ -271,7 +270,6 @@ this.attachments.push(attachment); this.render(); - this.trigger('attachments-changed'); }, async maybeAddAttachment(file) {