From f47b142a7a3a19429cdddb9b5b67ac45b05ac828 Mon Sep 17 00:00:00 2001 From: Ravi Singh Date: Thu, 20 Feb 2020 10:11:25 +0000 Subject: [PATCH] [FIX] website: debounce link dialog inputs to avoid useless page loading When we edit a link on the website, the target page is loaded to find the anchors. This occured at every typed character which was obviously not efficient. task-2187754 closes odoo/odoo#45831 X-original-commit: 06ae0b7b00c837733a9c67772007aee6712b246e Signed-off-by: Quentin Smetz (qsm) --- addons/website/static/src/js/editor/widget_link.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/website/static/src/js/editor/widget_link.js b/addons/website/static/src/js/editor/widget_link.js index 6baf51fb11c..9f3c1d276ba 100644 --- a/addons/website/static/src/js/editor/widget_link.js +++ b/addons/website/static/src/js/editor/widget_link.js @@ -15,7 +15,15 @@ weWidgets.LinkDialog.include({ custom_events: _.extend({}, weWidgets.LinkDialog.prototype.custom_events || {}, { website_url_chosen: '_onAutocompleteClose', }), + LINK_DEBOUNCE: 1000, + /** + * @constructor + */ + init: function () { + this._super.apply(this, arguments); + this._adaptPageAnchor = _.debounce(this._adaptPageAnchor, this.LINK_DEBOUNCE); + }, /** * Allows the URL input to propose existing website pages. *