bug1846742-microsoft.com-search-key-fix.js (850B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * www.microsoft.com - Pressing enter on search suggestions does nothing 9 * 10 * When pressing enter on a search suggestion, nothing happens in Firefox 11 * due to key-event interop issues. We listen for enter keypresses and 12 * click the element as a work-around. 13 */ 14 15 console.info( 16 "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." 17 ); 18 19 document.addEventListener("keydown", ({ target, key }) => { 20 if (key == "Enter" && target.matches(".m-auto-suggest a.f-product")) { 21 target.click(); 22 } 23 });