fix the send to many keyboard trap, close idle tables with escape, and name the search, scan and sweep dialog controls
What changed, and why it matters
This commit fixes keyboard and screen-reader accessibility issues in Sparrow Wallet. It makes the 'send to many' recipient grid easier to navigate with Tab and arrow keys, lets the Escape key close search-result tables and other dialogs as expected, and adds hidden labels so screen readers can describe the QR scan, search, and private-key sweep dialog controls. There is no direct evidence of a security vulnerability being patched.
Treat as a routine accessibility/UX fix. Reviewers may optionally verify that PrivateKeySweepDialog's new getKey() call does not introduce new exception paths that affect user workflow, but no security response is indicated.
Security signals we found
Private key parsing validation now calls getKey() to confirm the dumped key is usable
Escape-key handling broadened to cover tables in dialogs
No explicit security bug, CVE, or exploit mechanism present in diff
Evidence from the diff
The change is a collection of JavaFX accessibility improvements: (1) AppServices escape forwarding is generalized from closed MenuButtons to any ‘unused’ Escape target, including TableView/TreeTableView not in edit mode, so dialogs close on Escape; (2) SendToManyDialog adds Ctrl+Tab exit from the spreadsheet grid, removes the spreadsheet as a standalone Tab stop, auto-selects the first cell on focus, and adds an invisible label for the cell editor; (3) QRScanDialog, SearchWalletDialog, and PrivateKeySweepDialog add accessible text/labels and title/header consistency; (4) PrivateKeySweepDialog’s isValidKey() now calls getKey() on the parsed dumped private key to ensure it is actually usable. The last item is a minor robustness tweak, not a cryptographic fix.
Changed components
AppServices.javaSparrowDesktop.javaSendToManyDialog.javaQRScanDialog.javaSearchWalletDialog.javaPrivateKeySweepDialog.javaInspect captured patch +65 / −13
### src/main/java/com/sparrowwallet/sparrow/AppServices.java
@@ -107,10 +107,10 @@ public class AppServices {
private static final List<Double> LONG_FEE_RATES_RANGE = List.of(1d, 2d, 4d, 8d, 16d, 32d, 64d, 128d, 256d, 512d, 1024d, 2048d, 4096d, 8192d);
public static final double FALLBACK_FEE_RATE = 20000d / 1000;
public static final double TESTNET_FALLBACK_FEE_RATE = 1000d / 1000;
- private static final EventHandler<javafx.scene.input.KeyEvent> FORWARD_ESCAPE_FROM_CLOSED_MENU_BUTTON = event -> {
- if(event.getCode() == KeyCode.ESCAPE && event.getTarget() instanceof MenuButton menuButton && !menuButton.isShowing() && menuButton.getParent() != null) {
+ private static final EventHandler<javafx.scene.input.KeyEvent> FORWARD_UNUSED_ESCAPE = event -> {
+ if(event.getCode() == KeyCode.ESCAPE && event.getTarget() instanceof Node node && node.getParent() != null && isEscapeUnused(node)) {
event.consume();
- menuButton.getParent().fireEvent(event);
+ node.getParent().fireEvent(event);
}
};
private static final ChangeListener<Boolean> NOT_FOCUS_TRAVERSABLE = (observable, wasTraversable, traversable) -> {
@@ -738,19 +738,28 @@ public static void moveFocusOnTab(Node node) {
});
}
- //Menu buttons consume Escape even when their menu is closed, so Escape on a split button did not close its dialog.
- //Like a combo box, a closed menu button passes Escape on to its parent.
- public static void forwardEscapeFromClosedMenuButtons() {
+ //Menu buttons consume Escape even when their menu is closed, and tables consume it even when no cell is being edited, so Escape on a
+ //split button or in a table such as the search results did not close its dialog. Like a combo box, these pass Escape on to their parent.
+ public static void forwardUnusedEscape() {
Window.getWindows().addListener((ListChangeListener<Window>)change -> {
while(change.next()) {
for(Window window : change.getAddedSubList()) {
- window.removeEventFilter(javafx.scene.input.KeyEvent.KEY_PRESSED, FORWARD_ESCAPE_FROM_CLOSED_MENU_BUTTON);
- window.addEventFilter(javafx.scene.input.KeyEvent.KEY_PRESSED, FORWARD_ESCAPE_FROM_CLOSED_MENU_BUTTON);
+ window.removeEventFilter(javafx.scene.input.KeyEvent.KEY_PRESSED, FORWARD_UNUSED_ESCAPE);
+ window.addEventFilter(javafx.scene.input.KeyEvent.KEY_PRESSED, FORWARD_UNUSED_ESCAPE);
}
}
});
}
+ private static boolean isEscapeUnused(Node node) {
+ return switch(node) {
+ case MenuButton menuButton -> !menuButton.isShowing();
+ case TableView<?> tableView -> tableView.getEditingCell() == null;
+ case TreeTableView<?> treeTableView -> treeTableView.getEditingCell() == null;
+ default -> false;
+ };
+ }
+
//Charts make every data point a Tab stop while a screen reader is on, including points created before it started.
//The charts here are read as a one-line summary, so their points are kept out of the Tab order.
public static void keepChartPointsOutOfTabOrder(ObservableList<Node> plotChildren) {
### src/main/java/com/sparrowwallet/sparrow/SparrowDesktop.java
@@ -47,7 +47,7 @@ public void start(Stage stage) throws Exception {
AppServices.initialize(this);
AppServices.monitorSystemTheme();
- AppServices.forwardEscapeFromClosedMenuButtons();
+ AppServices.forwardUnusedEscape();
boolean createNewWallet = false;
Mode mode = Config.get().getMode();
### src/main/java/com/sparrowwallet/sparrow/control/PrivateKeySweepDialog.java
@@ -267,7 +267,7 @@ public ScriptType fromString(String string) {
private boolean isValidKey() {
try {
- DumpedPrivateKey privateKey = getPrivateKey();
+ getPrivateKey().getKey();
return true;
} catch(Exception e) {
return false;
### src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java
@@ -112,6 +112,7 @@ public QRScanDialog() {
progressBar.setPadding(new Insets(0, 10, 0, 10));
progressBar.setPrefWidth(Integer.MAX_VALUE);
progressBar.progressProperty().bind(percentComplete);
+ progressBar.setAccessibleText("Scan progress");
VBox vBox = new VBox(20);
StackPane stackPane = new StackPane();
@@ -215,6 +216,15 @@ public QRScanDialog() {
final ButtonType deviceButtonType = new javafx.scene.control.ButtonType("Default Camera", ButtonBar.ButtonData.LEFT);
final ButtonType resolutionButtonType = new javafx.scene.control.ButtonType("Resolution", ButtonBar.ButtonData.HELP_2);
dialogPane.getButtonTypes().addAll(deviceButtonType, resolutionButtonType, cancelButtonType);
+
+ //The camera and resolution pop-ups have no visible label, so hidden labels name them for screen readers
+ for(Map.Entry<String, ButtonType> popup : Map.of("Camera", deviceButtonType, "Resolution", resolutionButtonType).entrySet()) {
+ Label label = new Label(popup.getKey());
+ label.setLabelFor(dialogPane.lookupButton(popup.getValue()));
+ label.setVisible(false);
+ label.setManaged(false);
+ vBox.getChildren().add(label);
+ }
dialogPane.setPrefWidth(646);
dialogPane.setPrefHeight(webcamResolutionProperty.get().isWidescreenAspect() ? 490 : 590);
dialogPane.setMinHeight(dialogPane.getPrefHeight());
### src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java
@@ -59,7 +59,8 @@ public SearchWalletDialog(List<WalletForm> walletForms) {
dialogPane.getStylesheets().add(AppServices.class.getResource("wallet/wallet.css").toExternalForm());
dialogPane.getStylesheets().add(AppServices.class.getResource("search.css").toExternalForm());
AppServices.setStageIcon(dialogPane.getScene().getWindow());
- dialogPane.setHeaderText(showWallet ? "Search All Wallets" : "Search Wallet " + walletForms.get(0).getMasterWallet().getName());
+ setTitle(showWallet ? "Search All Wallets" : "Search Wallet " + walletForms.get(0).getMasterWallet().getName());
+ dialogPane.setHeaderText(getTitle());
dialogPane.setGraphic(new DialogImage(DialogImage.Type.SPARROW));
VBox vBox = new VBox();
@@ -160,7 +161,7 @@ public SearchWalletDialog(List<WalletForm> walletForms) {
setResultConverter(buttonType -> buttonType == showButtonType ? results.getSelectionModel().getSelectedItem().getValue() : null);
results.getSelectionModel().getSelectedIndices().addListener((ListChangeListener<Integer>) c -> {
- showButton.setDisable(results.getSelectionModel().getSelectedCells().isEmpty()
+ showButton.setDisable(results.getSelectionModel().getSelectedItem() == null
|| walletForms.stream().map(WalletForm::getWallet).noneMatch(wallet -> wallet == results.getSelectionModel().getSelectedItem().getValue().getWallet()));
});
### src/main/java/com/sparrowwallet/sparrow/control/SendToManyDialog.java
@@ -27,6 +27,7 @@
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.scene.Node;
+import javafx.scene.TraversalDirection;
import javafx.scene.control.*;
import javafx.scene.input.Clipboard;
import javafx.scene.input.KeyCode;
@@ -91,8 +92,39 @@ public void pasteClipboard() {
spreadsheetView.getColumns().get(1).setPrefWidth(150);
spreadsheetView.getColumns().get(2).setPrefWidth(247);
+ //The grid uses Tab to move between cells, so Control-Tab leaves it, as for other controls that keep Tab for themselves
+ spreadsheetView.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
+ if(event.getCode() == KeyCode.TAB && event.isControlDown() && event.getTarget() instanceof TableView<?> gridView) {
+ gridView.requestFocusTraversal(event.isShiftDown() ? TraversalDirection.PREVIOUS : TraversalDirection.NEXT);
+ event.consume();
+ }
+ });
+ //The view is a separate, invisible Tab stop before its grid, where Return reached the OK button
+ spreadsheetView.setFocusTraversable(false);
+ spreadsheetView.getChildrenUnmodifiable().stream().filter(TableView.class::isInstance).findFirst().ifPresent(gridView -> {
+ gridView.setAccessibleText("Recipients");
+ gridView.setAccessibleHelp("Press Control-Tab to leave the table");
+ });
+ //A grid reached from the keyboard has no cell to move from, so the arrow keys did nothing until a cell was clicked
+ spreadsheetView.focusWithinProperty().addListener((_, _, focused) -> {
+ if(focused && spreadsheetView.getSelectionModel().getSelectedCells().isEmpty()) {
+ spreadsheetView.getSelectionModel().clearAndSelect(0, spreadsheetView.getColumns().getFirst());
+ }
+ });
+ //A hidden label names the cell editor by column and row, as a name set on the editor itself would replace its text for screen readers
+ Label editorLabel = new Label();
+ editorLabel.setVisible(false);
+ editorLabel.setManaged(false);
+ spreadsheetView.editingCellProperty().addListener((_, _, position) -> {
+ if(position != null) {
+ SpreadsheetCell cell = spreadsheetView.getGrid().getRows().get(position.getRow()).get(position.getColumn());
+ editorLabel.setText(spreadsheetView.getGrid().getColumnHeaders().get(position.getColumn()) + ", row " + (position.getRow() + 1));
+ spreadsheetView.getEditor(cell.getCellType()).ifPresent(editor -> editorLabel.setLabelFor(editor.getEditor()));
+ }
+ });
+
StackPane stackPane = new StackPane();
- stackPane.getChildren().add(spreadsheetView);
+ stackPane.getChildren().addAll(spreadsheetView, editorLabel);
dialogPane.setContent(stackPane);
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);Why this scored 21/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.