mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1537712 - Listen for key modifiers in json view hotkeys r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D160148
This commit is contained in:
parent
56139a3664
commit
15b7791200
@ -62,7 +62,7 @@ add_task(async function() {
|
||||
".jsonPanelBox .panelContent"
|
||||
);
|
||||
ok(scroller.scrollTop > 0, "Not scrolled to the top.");
|
||||
// Synthetize up arrow key to select first row.
|
||||
// Synthesize up arrow key to select first row.
|
||||
content.document.querySelector(".treeTable").focus();
|
||||
});
|
||||
await BrowserTestUtils.synthesizeKey("VK_UP", {}, tab.linkedBrowser);
|
||||
@ -92,7 +92,7 @@ add_task(async function() {
|
||||
await clickJsonNode(".treeRow:first-child");
|
||||
await assertRowSelected(1);
|
||||
|
||||
// Synthetize multiple down arrow keydowns to select following rows.
|
||||
// Synthesize multiple down arrow keydowns to select following rows.
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
|
||||
content.document.querySelector(".treeTable").focus();
|
||||
});
|
||||
@ -105,12 +105,22 @@ add_task(async function() {
|
||||
await assertRowSelected(i);
|
||||
}
|
||||
|
||||
// Now synthetize the keyup, this shouldn't change selected row.
|
||||
// Now synthesize the keyup, this shouldn't change selected row.
|
||||
await BrowserTestUtils.synthesizeKey(
|
||||
"VK_DOWN",
|
||||
{ type: "keyup" },
|
||||
tab.linkedBrowser
|
||||
);
|
||||
await wait(500);
|
||||
await assertRowSelected(numRows - 1);
|
||||
|
||||
// Finally, synthesize keydown with a modifier, this also shouldn't change selected row.
|
||||
await BrowserTestUtils.synthesizeKey(
|
||||
"VK_DOWN",
|
||||
{ type: "keydown", shiftKey: true },
|
||||
tab.linkedBrowser
|
||||
);
|
||||
await wait(500);
|
||||
await assertRowSelected(numRows - 1);
|
||||
});
|
||||
|
||||
|
@ -345,14 +345,14 @@ define(function(require, exports, module) {
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
onKeyDown(event) {
|
||||
const keyEligibleForFirstLetterNavigation =
|
||||
event.key.length === 1 &&
|
||||
!event.ctrlKey &&
|
||||
!event.metaKey &&
|
||||
!event.altKey;
|
||||
const keyEligibleForFirstLetterNavigation = event.key.length === 1;
|
||||
if (
|
||||
!SUPPORTED_KEYS.includes(event.key) &&
|
||||
!keyEligibleForFirstLetterNavigation
|
||||
(!SUPPORTED_KEYS.includes(event.key) &&
|
||||
!keyEligibleForFirstLetterNavigation) ||
|
||||
event.shiftKey ||
|
||||
event.ctrlKey ||
|
||||
event.metaKey ||
|
||||
event.altKey
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@ -413,14 +413,12 @@ define(function(require, exports, module) {
|
||||
this.selectRow(firstRow, { alignTo: "top" });
|
||||
}
|
||||
break;
|
||||
|
||||
case "End":
|
||||
const lastRow = rows[rows.length - 1];
|
||||
if (lastRow) {
|
||||
this.selectRow(lastRow, { alignTo: "bottom" });
|
||||
}
|
||||
break;
|
||||
|
||||
case "Enter":
|
||||
case " ":
|
||||
// On space or enter make selected row active. This means keyboard
|
||||
|
Loading…
Reference in New Issue
Block a user