From b11eabbfd7eb100a71edc24a4bba0459eddc444f Mon Sep 17 00:00:00 2001 From: Romeo Fragomeli Date: Wed, 17 Feb 2021 15:22:22 +0000 Subject: [PATCH] [FIX] web: calendar: avoid rerendering on resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, when a calendar view was resized the full view was rendered again to recalculate the resize. After this commit, we now set manually the new size. This avoid to lose the current position-y in the calendar. Steps to reproduce: * Open a window (not maximized) * Go to calendar (day/week view) * Scroll to the end of the calendar * Resize the window => the calendar returns to the begging. Note: By the same way it also fixes a performance issue in TimeOff's render as it makes an RPC to calculate the popover for the year view. Task ID: 2200168 (5.a) closes odoo/odoo#66387 Signed-off-by: Adrien Dieudonné (adr) --- .../src/js/views/calendar/calendar_renderer.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/calendar/calendar_renderer.js b/addons/web/static/src/js/views/calendar/calendar_renderer.js index 23bb6885c28..fed9a705d11 100644 --- a/addons/web/static/src/js/views/calendar/calendar_renderer.js +++ b/addons/web/static/src/js/views/calendar/calendar_renderer.js @@ -524,7 +524,7 @@ return AbstractRenderer.extend({ return 'popover'; }, windowResize: function () { - self._render(); + self._onWindowResize(); }, views: { timeGridDay: { @@ -981,6 +981,16 @@ return AbstractRenderer.extend({ this._unselectEvent(); } }, + /** + * Handler for resize event. + * As the result it will resize the calendar to fit the window space. + * + * @private + */ + _onWindowResize: function () { + this.$el.height($(window).height() - this.$el.offset().top); + this.calendar.updateSize(); + }, /** * @private * @param {OdooEvent} event