name the connected devices button, keep focus on the device in device dialogs and read device and card errors as they appear
What changed, and why it matters
This commit improves accessibility for users who rely on screen readers. It gives names to buttons, keeps focus on the correct device or card dialog while operations run, and reads out errors as they appear. There is no direct evidence of a security vulnerability being fixed; the changes are about making the wallet easier and safer to use for people with visual impairments.
Treat as a regular accessibility/usability improvement. No urgent security action is required, but verify that focus behavior does not trap users or prevent keyboard cancellation of long-running operations.
Security signals we found
UI focus management changes in PIN-entry and device dialogs
Error state now announced to assistive technology
Stale error cleared before allowing PIN retry
No cryptographic, authentication, or network-layer modifications
Evidence from the diff
The patch modifies JavaFX UI code in Sparrow Wallet to enhance assistive-technology behavior. It adds accessible text to the USB status button, keeps focus inside device/card panes when action buttons disable themselves, sets initial focus to the first device in device dialogs, clears stale error status before PIN re-entry, and exposes dynamic error messages via accessible text/labels so screen readers announce them. No cryptographic, network, or privilege changes are present.
Changed components
src/main/java/com/sparrowwallet/sparrow/control/CardImportPane.javasrc/main/java/com/sparrowwallet/sparrow/control/DeviceDialog.javasrc/main/java/com/sparrowwallet/sparrow/control/DevicePane.javasrc/main/java/com/sparrowwallet/sparrow/control/TitledDescriptionPane.javasrc/main/java/com/sparrowwallet/sparrow/control/UsbStatusButton.javaInspect captured patch +81 / −0
### src/main/java/com/sparrowwallet/sparrow/control/CardImportPane.java
@@ -152,6 +152,7 @@ private Node getSeedInitializationPanel(StringProperty messageProperty) {
confirmationBox.getChildren().add(confirmationPin);
Button initializeButton = new Button("Initialize");
+ keepFocusWhenDisabled(initializeButton);
initializeButton.setDefaultButton(true);
initializeButton.setOnAction(event -> {
initializeButton.setDisable(true);
@@ -225,6 +226,7 @@ private Node getEntropyInitializationPanel(StringProperty messageProperty) {
initTypeBox.getChildren().addAll(automatic, advanced, entropy);
Button initializeButton = new Button("Initialize");
+ keepFocusWhenDisabled(initializeButton);
initializeButton.setDefaultButton(true);
initializeButton.setOnAction(event -> {
initializeButton.setDisable(true);
@@ -280,6 +282,7 @@ private Node getPinEntry() {
contentBox.setAlignment(Pos.TOP_RIGHT);
contentBox.setSpacing(20);
contentBox.getChildren().add(pinField);
+ labelPinField(pinField, contentBox);
contentBox.setPadding(new Insets(10, 30, 0, 30));
contentBox.setPrefHeight(50);
### src/main/java/com/sparrowwallet/sparrow/control/DeviceDialog.java
@@ -144,6 +144,8 @@ protected void setDevices(List<Device> devices) {
DevicePane devicePane = getDevicePane(device, dialogDevices.size() == 1);
deviceAccordion.getPanes().add(devicePane);
}
+ //Focus starts on the first device rather than the dialog's buttons, so the device and its state are read first
+ Platform.runLater(() -> deviceAccordion.getPanes().getFirst().requestFocus());
}
}
### src/main/java/com/sparrowwallet/sparrow/control/DevicePane.java
@@ -488,6 +488,8 @@ private Node getPinEntry() {
sendPin(pinField.getText());
});
vBox.getChildren().addAll(pinField, enterPinButton);
+ labelPinField(pinField, vBox);
+ keepFocusWhenDisabled(enterPinButton);
GridPane gridPane = new GridPane();
gridPane.setHgap(10);
@@ -599,6 +601,8 @@ private void promptPin() {
promptPinService.setOnSucceeded(workerStateEvent -> {
Boolean result = promptPinService.getValue();
if(result) {
+ //Clears an earlier error, which no longer applies once the PIN can be entered
+ setDefaultStatus();
setContent(getPinEntry());
setExpanded(true);
} else {
@@ -1311,6 +1315,7 @@ private Node getCardSeedInitializationPanel(CardApi cardApi, ButtonBase operatio
confirmationBox.getChildren().add(confirmationPin);
Button initializeButton = new Button("Initialize");
+ keepFocusWhenDisabled(initializeButton);
initializeButton.setDefaultButton(true);
initializeButton.setOnAction(event -> {
initializeButton.setDisable(true);
@@ -1384,6 +1389,7 @@ private Node getCardEntropyInitializationPanel(CardApi cardApi, ButtonBase opera
initTypeBox.getChildren().addAll(automatic, advanced, entropy);
Button initializeButton = new Button("Initialize");
+ keepFocusWhenDisabled(initializeButton);
initializeButton.setDefaultButton(true);
initializeButton.setOnAction(event -> {
initializeButton.setDisable(true);
@@ -1438,6 +1444,7 @@ private Node getCardPinEntry(ButtonBase operationButton) {
contentBox.setAlignment(Pos.TOP_RIGHT);
contentBox.setSpacing(20);
contentBox.getChildren().add(pinField);
+ labelPinField(pinField, contentBox);
contentBox.setPadding(new Insets(10, 30, 10, 30));
contentBox.setPrefHeight(50);
### src/main/java/com/sparrowwallet/sparrow/control/TitledDescriptionPane.java
@@ -7,11 +7,17 @@
import javafx.application.Platform;
import javafx.collections.ListChangeListener;
import javafx.beans.binding.Bindings;
+import javafx.beans.property.BooleanProperty;
+import javafx.beans.property.ReadOnlyProperty;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.value.ChangeListener;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
+import javafx.scene.AccessibleRole;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
@@ -21,6 +27,16 @@
public class TitledDescriptionPane extends TitledPane {
private Label mainLabel;
private Label descriptionLabel;
+ private final BooleanProperty showingError = new SimpleBooleanProperty(false);
+
+ //An action button disables itself while its operation runs, which would move focus on to the dialog's buttons. Focus stays on this
+ //pane instead, whose name includes the status line, so the operation's progress and result are read.
+ private final ChangeListener<Boolean> keepFocusWhenDisabled = (observable, wasDisabled, disabled) -> {
+ Node node = (Node)((ReadOnlyProperty<?>)observable).getBean();
+ if(disabled && node.getScene() != null && node.getScene().getFocusOwner() == node) {
+ requestFocus();
+ }
+ };
protected Hyperlink showHideLink;
protected HBox buttonBox;
@@ -62,6 +78,8 @@ protected Node getTitle(String title, String description, WalletModel walletMode
labelsBox.getChildren().add(descriptionBox);
descriptionLabel = new Label(description);
+ //A read-only text field, as screen readers keep the first value of static text and the line changes with the pane's state
+ descriptionLabel.setAccessibleRole(AccessibleRole.TEXT_FIELD);
descriptionLabel.getStyleClass().add("description-label");
showHideLink = new Hyperlink("Details...");
showHideLink.managedProperty().bind(showHideLink.visibleProperty());
@@ -82,6 +100,11 @@ protected Node getTitle(String title, String description, WalletModel walletMode
buttonBox = new HBox();
buttonBox.setAlignment(Pos.CENTER_RIGHT);
+ buttonBox.getChildren().addListener((ListChangeListener<Node>)change -> {
+ while(change.next()) {
+ change.getAddedSubList().forEach(this::keepFocusWhenDisabled);
+ }
+ });
Control button = createButton();
if(button != null) {
buttonBox.getChildren().add(button);
@@ -111,18 +134,63 @@ protected void setDescription(String text) {
descriptionLabel.getStyleClass().add("description-label");
}
descriptionLabel.setText(text);
+ showingError.set(false);
+ descriptionLabel.setAccessibleText(null);
+ descriptionLabel.setFocusTraversable(false);
}
protected void setError(String title, String detail) {
+ //Checked before the content is replaced, as removing the old content with focus in it clears focus from the pane straight away.
+ //The window's focus owner is used rather than focusWithin, which is false while the window is inactive.
+ boolean hadFocus = hasFocusOwner();
descriptionLabel.getStyleClass().remove("description-label");
if(!descriptionLabel.getStyleClass().contains("description-error")) {
descriptionLabel.getStyleClass().add("description-error");
}
descriptionLabel.setText(title);
+ showingError.set(true);
if(detail != null && !detail.isEmpty()) {
setContent(getContentBox(detail));
setExpanded(true);
}
+
+ //The error line is read as a named, read-only field holding the whole error, links included. A screen reader doesn't speak the
+ //new name of a pane that already has focus, so when focus is in this pane the error takes it to be read; focus elsewhere, such
+ //as another device, is left alone.
+ String spokenDetail = detail == null ? "" : detail.replaceAll("\\[(https?://\\S+)]", "$1").trim();
+ descriptionLabel.setAccessibleText(spokenDetail.isEmpty() ? title : title + ": " + spokenDetail);
+ descriptionLabel.setFocusTraversable(true);
+ if(hadFocus) {
+ Platform.runLater(descriptionLabel::requestFocus);
+ }
+ }
+
+ //A PIN entry shown again after a wrong PIN takes focus for the next try, so the field is named after the error while one is shown,
+ //which reads the error as focus arrives rather than the error line taking focus away from the field
+ protected void labelPinField(TextInputControl pinField, Pane container) {
+ Label pinLabel = new Label();
+ pinLabel.textProperty().bind(Bindings.createStringBinding(() -> showingError.get() ? descriptionLabel.getText() + ", PIN" : "PIN",
+ showingError, descriptionLabel.textProperty()));
+ pinLabel.setLabelFor(pinField);
+ pinLabel.setVisible(false);
+ pinLabel.setManaged(false);
+ container.getChildren().add(pinLabel);
+ }
+
+ private boolean hasFocusOwner() {
+ for(Node node = getScene() == null ? null : getScene().getFocusOwner(); node != null; node = node.getParent()) {
+ if(node == this) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ //Used for the button row, and for buttons in a pane's content that disable themselves, such as Enter PIN and Initialize
+ protected void keepFocusWhenDisabled(Node node) {
+ node.disabledProperty().removeListener(keepFocusWhenDisabled);
+ node.disabledProperty().addListener(keepFocusWhenDisabled);
}
protected Node getContentBox(String message) {
### src/main/java/com/sparrowwallet/sparrow/control/UsbStatusButton.java
@@ -19,6 +19,7 @@ public class UsbStatusButton extends MenuButton {
public UsbStatusButton() {
super("");
setGraphic(getIcon());
+ setAccessibleText("Connected Devices");
getStyleClass().add("status-bar-button");
this.setPopupSide(Side.RIGHT);Why this scored 20/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.