feat: add support for keyboard initialized menu popup (#38903)

* feat: add support for keyboard initialized menu popup

* Update docs/api/menu.md

Co-authored-by: Erick Zhao <erick@hotmail.ca>

* fix: add patch to chromium for keyboard accessibility menu behavior

* refactor: s/initiatedByKeyboard/sourceType

* fix: ignore initial mouse event to retain keyboard initiated focus

* Update docs/api/menu.md

Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>

---------

Co-authored-by: Erick Zhao <erick@hotmail.ca>
Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
This commit is contained in:
Samuel Attard 2023-06-29 15:54:06 -07:00 committed by GitHub
parent 607e71d563
commit 499d893040
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 282 additions and 33 deletions

View file

@ -69,7 +69,7 @@ Menu.prototype.popup = function (options = {}) {
if (options == null || typeof options !== 'object') {
throw new TypeError('Options must be an object');
}
let { window, x, y, positioningItem, callback } = options;
let { window, x, y, positioningItem, sourceType, callback } = options;
// no callback passed
if (!callback || typeof callback !== 'function') callback = () => {};
@ -78,6 +78,7 @@ Menu.prototype.popup = function (options = {}) {
if (typeof x !== 'number') x = -1;
if (typeof y !== 'number') y = -1;
if (typeof positioningItem !== 'number') positioningItem = -1;
if (typeof sourceType !== 'string' || !sourceType) sourceType = 'mouse';
// find which window to use
const wins = BaseWindow.getAllWindows();
@ -91,7 +92,7 @@ Menu.prototype.popup = function (options = {}) {
}
}
this.popupAt(window as unknown as BaseWindow, x, y, positioningItem, callback);
this.popupAt(window as unknown as BaseWindow, x, y, positioningItem, sourceType, callback);
return { browserWindow: window, x, y, position: positioningItem };
};