[FIX] website: prevent CTRL-K from focusing on browser's URL bar
Ever since the website is previewed in the iframe [1], pressing CTRL-K (or Meta-K on macOS) while previewing the website can result in focusing on the browser's URL bar on top of summoning the command palette. Steps to reproduce: - Preview the website - Click on the iframe to focus on it - Press CTRL|Meta - K - URL bar is focused This commit fixes that by preventing the default behaviour within the iframe and only summon the command palette. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-3035637 closes odoo/odoo#106483 X-original-commit: 797a0514b58a37efc5246a655339353c200b4214 Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { WebsiteTranslator } from '../../components/translator/translator';
|
||||
import { unslugHtmlDataObject } from '../../services/website_service';
|
||||
import {OptimizeSEODialog} from '@website/components/dialog/seo';
|
||||
import { routeToUrl } from "@web/core/browser/router_service";
|
||||
import { getActiveHotkey } from "@web/core/hotkeys/hotkey_service";
|
||||
|
||||
const { Component, onWillStart, onMounted, onWillUnmount, useRef, useEffect, useState } = owl;
|
||||
|
||||
@@ -364,6 +365,11 @@ export class WebsitePreview extends Component {
|
||||
}
|
||||
});
|
||||
this.iframe.el.contentDocument.addEventListener('keydown', ev => {
|
||||
if (getActiveHotkey(ev) === 'control+k' && !this.websiteContext.edition) {
|
||||
// Avoid for browsers to focus on the URL bar when pressing
|
||||
// CTRL-K from within the iframe.
|
||||
ev.preventDefault();
|
||||
}
|
||||
this.iframe.el.dispatchEvent(new KeyboardEvent('keydown', ev));
|
||||
});
|
||||
this.iframe.el.contentDocument.addEventListener('keyup', ev => {
|
||||
|
||||
Reference in New Issue
Block a user