diff --git a/addons/web/static/src/core/commands/command_palette.js b/addons/web/static/src/core/commands/command_palette.js index 605cfab33b6..29b4e76dff9 100644 --- a/addons/web/static/src/core/commands/command_palette.js +++ b/addons/web/static/src/core/commands/command_palette.js @@ -9,7 +9,7 @@ import { debounce } from "@web/core/utils/timing"; import { _lt } from "@web/core/l10n/translation"; const { Component, hooks } = owl; -const { onWillStart, useState } = hooks; +const { onWillStart, useRef, useState } = hooks; const DEFAULT_PLACEHOLDER = _lt("Search..."); const DEFAULT_EMPTY_MESSAGE = _lt("No result found"); @@ -93,6 +93,8 @@ export class CommandPalette extends Component { commands: [], }); + this.listboxRef = useRef("listbox"); + onWillStart(() => this.setCommandPaletteConfig(this.props.config)); } @@ -205,9 +207,8 @@ export class CommandPalette extends Component { } this.selectCommand(nextIndex); - const listbox = this.el.querySelector(".o_command_palette_listbox"); - const command = listbox.querySelector(`#o_command_${nextIndex}`); - scrollTo(command, { scrollable: listbox }); + const command = this.listboxRef.el.querySelector(`#o_command_${nextIndex}`); + scrollTo(command, { scrollable: this.listboxRef.el }); } onCommandClicked(index) { diff --git a/addons/web/static/src/core/commands/command_palette.xml b/addons/web/static/src/core/commands/command_palette.xml index 39c4f8877c0..9b012387dd7 100644 --- a/addons/web/static/src/core/commands/command_palette.xml +++ b/addons/web/static/src/core/commands/command_palette.xml @@ -8,7 +8,7 @@ -