diff --git a/addons/web/static/src/core/hotkeys/hotkey_service.js b/addons/web/static/src/core/hotkeys/hotkey_service.js index 3a8ee6cd363..158c139976d 100644 --- a/addons/web/static/src/core/hotkeys/hotkey_service.js +++ b/addons/web/static/src/core/hotkeys/hotkey_service.js @@ -125,10 +125,9 @@ export const hotkeyService = { reg.callback(); dispatched = true; } - if (!event.repeat && isAlted) { // Click on all elements having a data-hotkey attribute matching the actual hotkey. - const elems = activeElement.querySelectorAll(`[data-hotkey='${hotkey}' i]`); + const elems = ui.getVisibleElements(`[data-hotkey='${hotkey}' i]`); for (const el of elems) { // AAB: not sure it is enough, we might need to trigger all events that occur when you actually click el.focus(); diff --git a/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js b/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js index afb98277ac1..9cf113fbf85 100644 --- a/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js +++ b/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js @@ -78,6 +78,35 @@ QUnit.test("data-hotkey", async (assert) => { comp.destroy(); }); +QUnit.test("invisible data-hotkeys are not enabled. ", async (assert) => { + assert.expect(3); + + class MyComponent extends Component { + onClick() { + assert.step("click"); + } + } + MyComponent.template = xml` +