trisquel-icecat/icecat/browser/extensions/webcompat/injections/js/bug1846742-microsoft.com-search-key-fix.js
2025-10-06 02:35:48 -06:00

23 lines
849 B
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* www.microsoft.com - Pressing enter on search suggestions does nothing
*
* When pressing enter on a search suggestion, nothing happens in IceCat
* due to key-event interop issues. We listen for enter keypresses and
* click the element as a work-around.
*/
console.info(
"A simulated click is issued on search suggestions when enter is pressed on them for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1846742 for details."
);
document.addEventListener("keydown", ({ target, key }) => {
if (key == "Enter" && target.matches(".m-auto-suggest a.f-product")) {
target.click();
}
});