[FIX] website: correctly debounce adaptAnchor

Previously, we attempted to debounce in what appeared to be an override
of the onWillStart method, but this method doesn't actually exist on the
parent classes and as such is never registered with the onWillStart
hook. This commit fixes that by registering it in an override of the
setup method instead.

task-3439226

Part-of: odoo/odoo#139209
This commit is contained in:
Samuel Degueldre
2023-11-02 21:02:44 +00:00
committed by Romain Estievenart
parent bd8565be2b
commit eaa6e4fdb3
@@ -3,21 +3,13 @@
import { LinkTools } from '@web_editor/js/wysiwyg/widgets/link_tools';
import { patch } from "@web/core/utils/patch";
import { status, useEffect } from '@odoo/owl';
import { onWillStart, status, useEffect } from '@odoo/owl';
import wUtils from "@website/js/utils";
import { debounce } from "@web/core/utils/timing";
const LINK_DEBOUNCE = 1000;
patch(LinkTools.prototype, {
/**
*
* @override
*/
onWillStart() {
this._adaptPageAnchor = debounce(this._adaptPageAnchor, LINK_DEBOUNCE);
return super.onWillStart(...arguments);
},
/**
* Allows the URL input to propose existing website pages.
*
@@ -31,6 +23,9 @@ patch(LinkTools.prototype, {
setup() {
super.setup();
onWillStart(() => {
this._adaptPageAnchor = debounce(this._adaptPageAnchor, LINK_DEBOUNCE);
});
useEffect((container) => {
const input = container?.querySelector(`input[name="url"]`);
if (!input) {