diff --git a/content/developer/reference/frontend/hooks.rst b/content/developer/reference/frontend/hooks.rst index 301a374d4..cc63138a9 100644 --- a/content/developer/reference/frontend/hooks.rst +++ b/content/developer/reference/frontend/hooks.rst @@ -23,7 +23,7 @@ documents the list of hooks provided by the Odoo web framework. * - :ref:`useAssets ` - load assets * - :ref:`useAutofocus ` - - focus automatically a referenced element + - focus automatically an element referenced by autofocus * - :ref:`useBus ` - subscribe and unsubscribe to a bus * - :ref:`usePager ` @@ -61,10 +61,8 @@ Location Description ----------- -Focus automatically an element referenced by a component after its rendering if -that element was not already present in the dom. The focus of that element can -be forced at a future patch if the returning value (a function) of useAutofocus -is called. +Focus an element referenced by a t-ref="autofocus" in the current component as +soon as it appears in the DOM and if it was not displayed before. .. code-block:: javascript @@ -72,10 +70,7 @@ is called. class Comp { setup() { - const focusOnUpdate = useAutofocus("to_focus"); - } - onStateReset() { - focusOnUpdate(); + this.inputRef = useAutofocus(); } static template = "Comp"; } @@ -83,16 +78,15 @@ is called. .. code-block:: xml - + API --- -.. js:function:: useAutofocus([ref]) +.. js:function:: useAutofocus() - :param string ref: optional. If given, must be a t-ref value. Default is "autofocus" - :returns: a function to be called if focus must be forced on next patch. + :returns: the element reference. .. _frontend/hooks/usebus: