From 12a90c6bb9d36f495dc6a07114f9667c82ee5228 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Tue, 14 Feb 2023 08:45:56 -0500 Subject: [PATCH] Focus nearby Remove button in storage manager when hitting Remove The window shouldn't lose focus when you press Remove. --- src/manage-storage.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/manage-storage.js b/src/manage-storage.js index 19a0c02cd..0932ba0e2 100644 --- a/src/manage-storage.js +++ b/src/manage-storage.js @@ -45,7 +45,7 @@ const $message = $(E("p")).appendTo($storage_manager.$main).html( "Any images you've saved to your computer with File > Save will not be affected." ); - $storage_manager.$Button("Close", () => { + const $close = $storage_manager.$Button("Close", () => { $storage_manager.close(); }); @@ -63,6 +63,12 @@ $(E("td")).append($remove).appendTo($tr); $remove.on("click", () => { + // Focus the next or previous row's remove button, or the close button if there are no more rows. + // Try focusing controls in reverse order of priority, so the highest priority control gets focus. + $close.focus(); + $tr.prev().find(".remove-button").focus(); + $tr.next().find(".remove-button").focus(); + localStorage.removeItem(k); $tr.remove(); if ($table.find("tr").length == 0) {