diff --git a/addons/web/static/src/core/autofocus_hook.js b/addons/web/static/src/core/autofocus_hook.js index 71ab91e72f4..c061a1074a7 100644 --- a/addons/web/static/src/core/autofocus_hook.js +++ b/addons/web/static/src/core/autofocus_hook.js @@ -26,15 +26,18 @@ export function useAutofocus(params = {}) { } const selector = params.selector || "[autofocus]"; let forceFocusCount = 0; - useEffect(function autofocus(target) { - if (target) { - target.focus(); - if (["INPUT", "TEXTAREA"].includes(target.tagName)) { - const inputEl = target; - inputEl.selectionStart = inputEl.selectionEnd = inputEl.value.length; + useEffect( + function autofocus(target) { + if (target) { + target.focus(); + if (["INPUT", "TEXTAREA"].includes(target.tagName)) { + const inputEl = target; + inputEl.selectionStart = inputEl.selectionEnd = inputEl.value.length; + } } - } - }, () => [comp.el.querySelector(selector), forceFocusCount]); + }, + () => [comp.el.querySelector(selector), forceFocusCount] + ); return function focusOnUpdate() { forceFocusCount++; // force the effect to rerun on next patch diff --git a/addons/web/static/src/core/bus_hook.js b/addons/web/static/src/core/bus_hook.js index 03920472031..c3f28169a57 100644 --- a/addons/web/static/src/core/bus_hook.js +++ b/addons/web/static/src/core/bus_hook.js @@ -30,8 +30,11 @@ const { useComponent } = owl.hooks; */ export function useBus(bus, eventName, callback) { const component = useComponent(); - useEffect(() => { - bus.on(eventName, component, callback); - return () => bus.off(eventName, component); - }, () => []); + useEffect( + () => { + bus.on(eventName, component, callback); + return () => bus.off(eventName, component); + }, + () => [] + ); } diff --git a/addons/web/static/src/core/dropdown/dropdown.js b/addons/web/static/src/core/dropdown/dropdown.js index 906f0efc783..5fde9645181 100644 --- a/addons/web/static/src/core/dropdown/dropdown.js +++ b/addons/web/static/src/core/dropdown/dropdown.js @@ -53,27 +53,32 @@ export class Dropdown extends Component { this.close(); } }); - useEffect(() => { - Promise.resolve().then(() => { - this.myActiveEl = this.ui.activeElement; - }); - }, () => []); + useEffect( + () => { + Promise.resolve().then(() => { + this.myActiveEl = this.ui.activeElement; + }); + }, + () => [] + ); // Set up key navigation ----------------------------------------------- this.hotkeyService = useService("hotkey"); this.hotkeyRemoves = []; const nextActiveIndexFns = { - "FIRST": () => 0, - "LAST": (items) => items.length - 1, - "NEXT": (items, prevActiveIndex) => Math.min(prevActiveIndex + 1, items.length - 1), - "PREV": (_, prevActiveIndex) => Math.max(0, prevActiveIndex - 1), + FIRST: () => 0, + LAST: (items) => items.length - 1, + NEXT: (items, prevActiveIndex) => Math.min(prevActiveIndex + 1, items.length - 1), + PREV: (_, prevActiveIndex) => Math.max(0, prevActiveIndex - 1), }; /** @type {(direction: "FIRST"|"LAST"|"NEXT"|"PREV") => Function} */ function activeItemSetter(direction) { return function () { - const items = [...this.el.querySelectorAll(":scope > ul.o_dropdown_menu > .o_dropdown_item")]; + const items = [ + ...this.el.querySelectorAll(":scope > ul.o_dropdown_menu > .o_dropdown_item"), + ]; const prevActiveIndex = items.findIndex((item) => [...item.classList].includes("o_dropdown_active") ); @@ -85,11 +90,11 @@ export class Dropdown extends Component { } const hotkeyCallbacks = { - "arrowdown": activeItemSetter("NEXT").bind(this), - "arrowup": activeItemSetter("PREV").bind(this), + arrowdown: activeItemSetter("NEXT").bind(this), + arrowup: activeItemSetter("PREV").bind(this), "shift+arrowdown": activeItemSetter("LAST").bind(this), "shift+arrowup": activeItemSetter("FIRST").bind(this), - "enter": () => { + enter: () => { const activeItem = this.el.querySelector( ":scope > ul.o_dropdown_menu > .o_dropdown_item.o_dropdown_active" ); @@ -97,7 +102,7 @@ export class Dropdown extends Component { activeItem.click(); } }, - "escape": this.close.bind(this), + escape: this.close.bind(this), }; /** @this {Dropdown} */ diff --git a/addons/web/static/src/core/l10n/currency.js b/addons/web/static/src/core/l10n/currency.js index 598bd5c297d..4fc3844493d 100644 --- a/addons/web/static/src/core/l10n/currency.js +++ b/addons/web/static/src/core/l10n/currency.js @@ -49,7 +49,7 @@ export function formatCurrency(value, cid, options = {}) { * @param {number} [options.currencyId] * @returns {number} float */ - export function parseCurrency(value, options = {}) { +export function parseCurrency(value, options = {}) { let values = value.split(" "); if (values.length === 1) { return parseFloat(value); diff --git a/addons/web/static/src/core/ui_service.js b/addons/web/static/src/core/ui_service.js index ab1e1c84cd7..6d7f8ff9961 100644 --- a/addons/web/static/src/core/ui_service.js +++ b/addons/web/static/src/core/ui_service.js @@ -25,10 +25,13 @@ export const SIZES = { XS: 0, VSM: 1, SM: 2, MD: 3, LG: 4, XL: 5, XXL: 6 }; export function useActiveElement(refName = null) { const uiService = useService("ui"); const owner = refName ? useRef(refName) : Component.current; - useEffect(() => { - uiService.activateElement(owner.el); - return () => uiService.deactivateElement(owner.el); - }, () => []); + useEffect( + () => { + uiService.activateElement(owner.el); + return () => uiService.deactivateElement(owner.el); + }, + () => [] + ); } export const uiService = { diff --git a/addons/web/static/src/env.js b/addons/web/static/src/env.js index 5578984c354..ae41caaa84d 100644 --- a/addons/web/static/src/env.js +++ b/addons/web/static/src/env.js @@ -134,13 +134,17 @@ async function _startServices(env, toStart, timeoutId) { if (toStart.size) { const names = [...toStart].map((s) => s.name); const missingDeps = new Set(); - [...toStart].forEach((s) => s.dependencies.forEach((dep) => { - if (!(dep in services) && !names.includes(dep)) { - missingDeps.add(dep); - } - })); + [...toStart].forEach((s) => + s.dependencies.forEach((dep) => { + if (!(dep in services) && !names.includes(dep)) { + missingDeps.add(dep); + } + }) + ); const depNames = [...missingDeps].join(", "); - throw new Error(`Some services could not be started: ${names}. Missing dependencies: ${depNames}`); + throw new Error( + `Some services could not be started: ${names}. Missing dependencies: ${depNames}` + ); } function findNext() { diff --git a/addons/web/static/src/legacy/legacy_dialog.js b/addons/web/static/src/legacy/legacy_dialog.js index bc3433ab2ec..192a204323b 100644 --- a/addons/web/static/src/legacy/legacy_dialog.js +++ b/addons/web/static/src/legacy/legacy_dialog.js @@ -14,9 +14,12 @@ const { hooks } = owl; patch(Dialog.prototype, "Legacy Adapted Dialog", { setup() { this._super(); - useEffect(() => { - OwlDialog.display(this); - return () => OwlDialog.hide(this); - }, () => []); + useEffect( + () => { + OwlDialog.display(this); + return () => OwlDialog.hide(this); + }, + () => [] + ); }, }); diff --git a/addons/web/static/src/webclient/actions/action_hook.js b/addons/web/static/src/webclient/actions/action_hook.js index a7e5b1fafbe..c592f2daf4a 100644 --- a/addons/web/static/src/webclient/actions/action_hook.js +++ b/addons/web/static/src/webclient/actions/action_hook.js @@ -18,22 +18,25 @@ const scrollSymbol = Symbol("scroll"); export function useSetupAction(params) { const component = useComponent(); - useEffect(() => { - if (component.props.registerCallback) { - if (params.beforeLeave) { - component.props.registerCallback("beforeLeave", params.beforeLeave); - } - component.props.registerCallback("export", () => { - const state = {}; - state[scrollSymbol] = getScrollPosition(component); - if (params.export) { - Object.assign(state, params.export()); + useEffect( + () => { + if (component.props.registerCallback) { + if (params.beforeLeave) { + component.props.registerCallback("beforeLeave", params.beforeLeave); } - return state; - }); - } - if (component.props.state) { - setScrollPosition(component, component.props.state[scrollSymbol]); - } - }, () => []); + component.props.registerCallback("export", () => { + const state = {}; + state[scrollSymbol] = getScrollPosition(component); + if (params.export) { + Object.assign(state, params.export()); + } + return state; + }); + } + if (component.props.state) { + setScrollPosition(component, component.props.state[scrollSymbol]); + } + }, + () => [] + ); } diff --git a/addons/web/static/src/webclient/clickbot/clickbot.js b/addons/web/static/src/webclient/clickbot/clickbot.js index c36e698b89b..c9ff40cf905 100644 --- a/addons/web/static/src/webclient/clickbot/clickbot.js +++ b/addons/web/static/src/webclient/clickbot/clickbot.js @@ -8,11 +8,11 @@ const MOUSE_EVENTS = ["mouseover", "mouseenter", "mousedown", "mouseup", "click"]; const BLACKLISTED_MENUS = [ - 'base.menu_theme_store', - 'base.menu_third_party', - 'account.menu_action_account_bank_journal_form', - 'pos_adyen.menu_pos_adyen_account', - 'payment_odoo.menu_adyen_account', + "base.menu_theme_store", + "base.menu_third_party", + "account.menu_action_account_bank_journal_form", + "pos_adyen.menu_pos_adyen_account", + "payment_odoo.menu_adyen_account", ]; const { isEnterprise } = odoo.info; diff --git a/addons/web/static/src/webclient/effects/rainbow_man.js b/addons/web/static/src/webclient/effects/rainbow_man.js index befd1afdcbf..bfe40b24d3a 100644 --- a/addons/web/static/src/webclient/effects/rainbow_man.js +++ b/addons/web/static/src/webclient/effects/rainbow_man.js @@ -30,12 +30,15 @@ export class RainbowMan extends Component { const delay = fadeout ? RainbowMan.rainbowFadeouts[fadeout] : false; this.delay = typeof delay === "number" ? delay : false; if (this.delay !== false) { - useEffect(() => { - const timeout = browser.setTimeout(() => { - this.el.classList.add("o_reward_fading"); - }, this.delay); - return () => browser.clearTimeout(timeout); - }, () => []); + useEffect( + () => { + const timeout = browser.setTimeout(() => { + this.el.classList.add("o_reward_fading"); + }, this.delay); + return () => browser.clearTimeout(timeout); + }, + () => [] + ); } } diff --git a/addons/web/static/src/webclient/webclient.js b/addons/web/static/src/webclient/webclient.js index 40923ae44f2..3a3dd36ecb4 100644 --- a/addons/web/static/src/webclient/webclient.js +++ b/addons/web/static/src/webclient/webclient.js @@ -26,9 +26,12 @@ export class WebClient extends Component { this.el.classList.toggle("o_fullscreen", mode === "fullscreen"); } }); - useEffect(() => { - this.loadRouterState(); - }, () => []); + useEffect( + () => { + this.loadRouterState(); + }, + () => [] + ); } mounted() { diff --git a/addons/web/static/tests/webclient/actions/report_action_tests.js b/addons/web/static/tests/webclient/actions/report_action_tests.js index 7f819e03dd5..9e4c48cd54b 100644 --- a/addons/web/static/tests/webclient/actions/report_action_tests.js +++ b/addons/web/static/tests/webclient/actions/report_action_tests.js @@ -93,7 +93,7 @@ QUnit.module("ActionManager", (hooks) => { assert.step("notify"); }, () => {} - ), + ) ); mockDownload((options) => { assert.step(options.url); @@ -131,7 +131,7 @@ QUnit.module("ActionManager", (hooks) => { assert.step("notify"); }, () => {} - ), + ) ); const mockRPC = async (route, args) => { assert.step(args.method || route);