let escape close dialogs from split buttons, name the port fields and read out the test connection result
What changed, and why it matters
This commit improves accessibility and keyboard navigation in the Sparrow Wallet desktop app. It lets the Escape key close dialogs that contain split menu buttons, gives screen readers a name for network port fields, and moves focus to the connection test result so assistive tools announce it. There is no security vulnerability here.
No security action needed. Treat as a normal accessibility/usability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds an event filter that forwards Escape key events from closed MenuButtons to their parent so dialogs close correctly. It also adds hidden labels (labelFor) for proxy/core/electrum port text fields so screen readers can name them, and calls requestFocus() on the test results label after a server connection test succeeds or fails so the result is announced. These are UI/UX and a11y fixes only.
Changed components
AppServices.javaSparrowDesktop.javaServerSettingsController.javaserver.fxmlInspect captured patch +29 / −0
### src/main/java/com/sparrowwallet/sparrow/AppServices.java
@@ -42,6 +42,7 @@
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
+import javafx.event.EventHandler;
import javafx.concurrent.Worker;
import javafx.fxml.FXMLLoader;
import javafx.scene.AccessibleRole;
@@ -106,6 +107,12 @@ 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) {
+ event.consume();
+ menuButton.getParent().fireEvent(event);
+ }
+ };
private static final ChangeListener<Boolean> NOT_FOCUS_TRAVERSABLE = (observable, wasTraversable, traversable) -> {
if(traversable) {
((Node)((ReadOnlyProperty<?>)observable).getBean()).setFocusTraversable(false);
@@ -731,6 +738,19 @@ 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() {
+ 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);
+ }
+ }
+ });
+ }
+
//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,6 +47,7 @@ public void start(Stage stage) throws Exception {
AppServices.initialize(this);
AppServices.monitorSystemTheme();
+ AppServices.forwardEscapeFromClosedMenuButtons();
boolean createNewWallet = false;
Mode mode = Config.get().getMode();
### src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java
@@ -680,6 +680,8 @@ private void showConnectionSuccess(List<String> serverVersion, String serverBann
if(serverBanner != null) {
testResults.setText(testResults.getText() + "\nServer Banner: " + serverBanner);
}
+ //Focus moves to the result so it is read out once the test finishes
+ testResults.requestFocus();
}
private void showConnectionFailure(Throwable exception) {
@@ -728,6 +730,7 @@ private void showConnectionFailure(Throwable exception) {
testResults.setText("Could not connect:\n\n" + reason);
testConnection.setGraphic(getGlyph(FontAwesome5.Glyph.EXCLAMATION_CIRCLE, "failure"));
+ testResults.requestFocus();
}
private void setupValidation() {
### src/main/resources/com/sparrowwallet/sparrow/settings/server.fxml
@@ -93,6 +93,7 @@
<Field text="Proxy URL:">
<TextField fx:id="publicProxyHost" promptText="e.g. 127.0.0.1" />
<TextField fx:id="publicProxyPort" maxWidth="120" promptText="e.g. 9050/9150" />
+ <Label text="Proxy port" labelFor="$publicProxyPort" visible="false" managed="false" />
</Field>
</Fieldset>
</Form>
@@ -105,6 +106,7 @@
<ComboBoxTextField fx:id="coreHost" promptText="e.g. 127.0.0.1" comboProperty="$recentCoreServers" />
</StackPane>
<TextField fx:id="corePort" promptText="e.g. 8332" maxWidth="120" />
+ <Label text="Port" labelFor="$corePort" visible="false" managed="false" />
</Field>
<Field text="Authentication:">
<SegmentedButton>
@@ -143,6 +145,7 @@
<Field text="Proxy URL:">
<TextField fx:id="coreProxyHost" promptText="e.g. 127.0.0.1" />
<TextField fx:id="coreProxyPort" maxWidth="120" promptText="e.g. 9050/9150" />
+ <Label text="Proxy port" labelFor="$coreProxyPort" visible="false" managed="false" />
</Field>
</Fieldset>
</Form>
@@ -155,6 +158,7 @@
<ComboBoxTextField fx:id="electrumHost" promptText="e.g. 127.0.0.1 or Tor hostname (.onion)" comboProperty="$recentElectrumServers" />
</StackPane>
<TextField fx:id="electrumPort" promptText="e.g. 50001" maxWidth="120" />
+ <Label text="Port" labelFor="$electrumPort" visible="false" managed="false" />
</Field>
<Field text="Use SSL:">
<UnlabeledToggleSwitch fx:id="electrumUseSsl"/>
@@ -173,6 +177,7 @@
<Field text="Proxy URL:">
<TextField fx:id="proxyHost" promptText="e.g. 127.0.0.1" />
<TextField fx:id="proxyPort" maxWidth="120" promptText="e.g. 9050/9150" />
+ <Label text="Proxy port" labelFor="$proxyPort" visible="false" managed="false" />
</Field>
</Fieldset>
</Form>Why this scored 15/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.