From c4e84115c2ca31966971f2a97c67566879805f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 7 Sep 2022 21:58:38 +0000 Subject: [PATCH] [FIX] mail: remove manual .update() in onScrollActiveCategory This computed field was manually updating a field, which is not correct. Instead, this field should have been an `onChange`, which is what this commit does as a fix. Task-2976940 Part-of: odoo/odoo#99556 --- .../mail/static/src/models/emoji_grid_view.js | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/addons/mail/static/src/models/emoji_grid_view.js b/addons/mail/static/src/models/emoji_grid_view.js index c0ab7bfc8f7..6c33a8554b3 100644 --- a/addons/mail/static/src/models/emoji_grid_view.js +++ b/addons/mail/static/src/models/emoji_grid_view.js @@ -21,6 +21,19 @@ registerModel({ onScroll() { this.onScrollThrottle.do(); }, + _onChangeScrollRecomputeCount() { + for (const viewCategory of this.emojiPickerViewOwner.categories) { + const rowIndex = this.firstRenderedRowIndex + this.topBufferAmount; + if ( + viewCategory.emojiGridRowView && + rowIndex >= viewCategory.emojiGridRowView.index && + (viewCategory.emojiPickerViewOwnerAsLastCategory || rowIndex <= viewCategory.endSectionIndex) + ) { + this.emojiPickerViewOwner.update({ activeCategoryByGridViewScroll: viewCategory }); + break; + } + } + }, /** * @private * @returns {boolean} @@ -112,22 +125,6 @@ registerModel({ inverse: 'emojiGridViewOwnerAsNonSearch', isCausal: true, }), - onScrollActiveCategory: attr({ - compute() { - this.scrollRecomputeCount; // observe scroll changes - for (const viewCategory of this.emojiPickerViewOwner.categories) { - const rowIndex = this.firstRenderedRowIndex + this.topBufferAmount; - if ( - viewCategory.emojiGridRowView && - rowIndex >= viewCategory.emojiGridRowView.index && - (viewCategory.emojiPickerViewOwnerAsLastCategory || rowIndex <= viewCategory.endSectionIndex) - ) { - this.emojiPickerViewOwner.update({ activeCategoryByGridViewScroll: viewCategory }); - break; - } - } - }, - }), onScrollThrottle: one('Throttle', { compute() { return { func: () => this.update({ scrollRecomputeCount: increment() }) }; @@ -200,4 +197,10 @@ registerModel({ }, }), }, + onChanges: [ + { + dependencies: ['scrollRecomputeCount'], + methodName: '_onChangeScrollRecomputeCount', + }, + ], });