give wallet and transaction tabs their name as tab text so screen readers can read it
What changed, and why it matters
This commit improves accessibility for users who rely on screen readers. Previously, wallet and transaction tabs in the Sparrow Wallet app used a hidden label structure, so screen readers couldn't announce the tab names. The change puts the actual wallet or transaction name directly on the tab, making it readable by assistive technology. There is no security vulnerability or malicious change visible in the diff.
No security action required. This is an accessibility/usability improvement. Review as part of normal QA if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors JavaFX tab construction in AppController.java so that Tab.setText(name) carries the visible/announced tab name instead of wrapping a Label inside the tab graphic. Wallet tabs now use the wallet name as tab text with a WalletIcon as the graphic; transaction tabs use the transaction name with a glyph wrapped in a StackPane. CSS is updated to preserve layout (graphic-text-gap, content-display: graphic-only, width capping via a new long-transaction-tab class). TabEvent.getTabName() now reads tab.getText() directly. No security-sensitive logic, input handling, cryptography, or network code is modified.
Changed components
src/main/java/com/sparrowwallet/sparrow/AppController.javasrc/main/java/com/sparrowwallet/sparrow/event/TabEvent.javasrc/main/resources/com/sparrowwallet/sparrow/app.csssrc/main/resources/com/sparrowwallet/sparrow/darktheme.cssInspect captured patch +63 / −46
### src/main/java/com/sparrowwallet/sparrow/AppController.java
@@ -57,6 +57,7 @@
import javafx.scene.input.*;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
+import javafx.scene.text.Font;
import javafx.stage.*;
import javafx.stage.Window;
import javafx.util.Duration;
@@ -83,6 +84,7 @@ public class AppController implements Initializable {
private static final Logger log = LoggerFactory.getLogger(AppController.class);
public static final String DRAG_OVER_CLASS = "drag-over";
+ public static final String LONG_TRANSACTION_TAB_CLASS = "long-transaction-tab";
public static final int TAB_LABEL_MAX_WIDTH = 300;
public static final double TAB_LABEL_GRAPHIC_OPACITY_INACTIVE = 0.8;
public static final double TAB_LABEL_GRAPHIC_OPACITY_ACTIVE = 0.95;
@@ -334,10 +336,9 @@ void initializeView() {
if(tabs.getTabs().contains(previouslySelectedTab)) {
this.previouslySelectedTab = previouslySelectedTab;
}
- tabs.getTabs().forEach(tab -> ((Label)tab.getGraphic()).getGraphic().setOpacity(TAB_LABEL_GRAPHIC_OPACITY_INACTIVE));
+ tabs.getTabs().forEach(tab -> tab.getGraphic().setOpacity(TAB_LABEL_GRAPHIC_OPACITY_INACTIVE));
if(selectedTab != null) {
- Label tabLabel = (Label)selectedTab.getGraphic();
- tabLabel.getGraphic().setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE);
+ selectedTab.getGraphic().setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE);
TabData tabData = (TabData)selectedTab.getUserData();
if(tabData.getType() == TabData.TabType.TRANSACTION) {
@@ -760,7 +761,7 @@ public void saveTransaction(ActionEvent event) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save Transaction");
- String fileName = ((Label)selectedTab.getGraphic()).getText();
+ String fileName = selectedTab.getText();
if(fileName != null && !fileName.isEmpty()) {
if(fileName.endsWith(".psbt")) {
fileName = fileName.substring(0, fileName.length() - ".psbt".length());
@@ -836,7 +837,7 @@ public void savePSBT(boolean asText, boolean includeXpubs) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save PSBT");
- String fileName = ((Label)selectedTab.getGraphic()).getText();
+ String fileName = selectedTab.getText();
if(fileName != null && !fileName.isEmpty()) {
fileName = fileName.replace('/', '_');
if(!fileName.endsWith(".psbt")) {
@@ -1764,13 +1765,10 @@ public void addWalletTab(Storage storage, Wallet wallet) {
if(!name.equals(wallet.getName())) {
wallet.setName(name);
}
- Tab tab = new Tab("");
+ Tab tab = new Tab(name);
WalletIcon walletIcon = new WalletIcon(storage, wallet);
walletIcon.setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE);
- Label tabLabel = new Label(name);
- tabLabel.setGraphic(walletIcon);
- tabLabel.setGraphicTextGap(5.0);
- tab.setGraphic(tabLabel);
+ tab.setGraphic(walletIcon);
tab.setClosable(true);
TabPane subTabs = new TabPane();
@@ -1886,6 +1884,7 @@ public WalletForm addWalletSubTab(TabPane subTabs, Storage storage, Wallet walle
subTabLabel.setTooltip(new Tooltip(label));
}
subTab.setGraphic(subTabLabel);
+ subTab.textProperty().bind(subTabLabel.textProperty());
FXMLLoader walletLoader = new FXMLLoader(getClass().getResource("wallet/wallet.fxml"));
subTab.setContent(walletLoader.load());
WalletController controller = walletLoader.getController();
@@ -2134,19 +2133,15 @@ private void addTransactionTab(String name, File file, Transaction transaction,
tabName = "[" + transaction.getTxId().toString().substring(0, 6) + "]";
}
- Tab tab = new Tab("");
+ Tab tab = new Tab(tabName);
Glyph glyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND);
glyph.setFontSize(10.0);
- glyph.setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE);
- Label tabLabel = new Label(tabName);
- tabLabel.setMaxWidth(TAB_LABEL_MAX_WIDTH);
- tabLabel.setGraphic(glyph);
- tabLabel.setGraphicTextGap(5.0);
- if(TextUtils.computeTextWidth(tabLabel.getFont(), tabName, 0.0D) > TAB_LABEL_MAX_WIDTH) {
- Tooltip tooltip = new Tooltip(tabName);
- tabLabel.setTooltip(tooltip);
- }
- tab.setGraphic(tabLabel);
+ //Wrapped so the tabs overflow menu, which can only copy Label and ImageView graphics, does not copy the glyph without its font
+ StackPane glyphPane = new StackPane(glyph);
+ glyphPane.setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE);
+ setTransactionTabWidth(tab);
+ tab.textProperty().addListener((observable, oldValue, newValue) -> setTransactionTabWidth(tab));
+ tab.setGraphic(glyphPane);
tab.setContextMenu(getTabContextMenu(tab));
tab.setClosable(true);
FXMLLoader transactionLoader = new FXMLLoader(getClass().getResource("transaction/transaction.fxml"));
@@ -2307,15 +2302,25 @@ private boolean confirmUnknownScriptOutputs(List<TransactionOutput> unknownScrip
}
private String getTabName(Tab tab) {
- return ((Label)tab.getGraphic()).getText();
+ return tab.getText();
}
private void setTabName(Tab tab, String name){
if(name != null && !name.isEmpty()) {
- ((Label)tab.getGraphic()).setText(name);
+ tab.setText(name);
}
}
+ //The tab header sizes its label to the label's preferred width, so a long name is capped through the preferred width
+ private void setTransactionTabWidth(Tab tab) {
+ boolean longName = TextUtils.computeTextWidth(Font.getDefault(), tab.getText(), 0.0D) > TAB_LABEL_MAX_WIDTH;
+ tab.getStyleClass().remove(LONG_TRANSACTION_TAB_CLASS);
+ if(longName) {
+ tab.getStyleClass().add(LONG_TRANSACTION_TAB_CLASS);
+ }
+ tab.setTooltip(longName ? new Tooltip(tab.getText()) : null);
+ }
+
private ContextMenu getTabContextMenu(Tab tab) {
ContextMenu contextMenu = new ContextMenu();
@@ -2681,19 +2686,18 @@ private void tabLabelStartAnimation(Transaction transaction) {
}
private void tabLabelStartAnimation(Tab tab) {
- Label tabLabel = (Label) tab.getGraphic();
- if(tabLabel.getUserData() == null) {
- Timeline timeline = AnimationUtil.getPulse(tabLabel.getGraphic(), Duration.millis(1000), tabLabel.getGraphic().getOpacity(), 0.1, 8);
+ Node graphic = tab.getGraphic();
+ if(graphic.getUserData() == null) {
+ Timeline timeline = AnimationUtil.getPulse(graphic, Duration.millis(1000), graphic.getOpacity(), 0.1, 8);
timeline.play();
- tabLabel.setUserData(timeline);
+ graphic.setUserData(timeline);
}
}
private void tabLabelAddFailure(Tab tab) {
- Label tabLabel = (Label)tab.getGraphic();
- WalletIcon walletIcon = (WalletIcon)tabLabel.getGraphic();
+ WalletIcon walletIcon = (WalletIcon)tab.getGraphic();
if(walletIcon.addFailure()) {
- tabLabel.setTooltip(new Tooltip("Error loading transaction history from server"));
+ tab.setTooltip(new Tooltip("Error loading transaction history from server"));
}
}
@@ -2714,20 +2718,19 @@ private void tabLabelStopAnimation(Transaction transaction) {
}
private void tabLabelStopAnimation(Tab tab) {
- Label tabLabel = (Label) tab.getGraphic();
- if(tabLabel.getUserData() != null) {
- Animation animation = (Animation)tabLabel.getUserData();
+ Node graphic = tab.getGraphic();
+ if(graphic.getUserData() != null) {
+ Animation animation = (Animation)graphic.getUserData();
animation.stop();
- tabLabel.setUserData(null);
- tabLabel.getGraphic().setOpacity(tab.isSelected() ? TAB_LABEL_GRAPHIC_OPACITY_ACTIVE : TAB_LABEL_GRAPHIC_OPACITY_INACTIVE);
+ graphic.setUserData(null);
+ graphic.setOpacity(tab.isSelected() ? TAB_LABEL_GRAPHIC_OPACITY_ACTIVE : TAB_LABEL_GRAPHIC_OPACITY_INACTIVE);
}
}
private void tabLabelRemoveFailure(Tab tab) {
- Label tabLabel = (Label)tab.getGraphic();
- WalletIcon walletIcon = (WalletIcon)tabLabel.getGraphic();
+ WalletIcon walletIcon = (WalletIcon)tab.getGraphic();
walletIcon.removeFailure();
- tabLabel.setTooltip(null);
+ tab.setTooltip(null);
}
private void setTorIcon() {
@@ -2777,8 +2780,7 @@ public void themeChanged(ThemeChangedEvent event) {
for(Tab tab : tabs.getTabs()) {
if(tab.getUserData() instanceof WalletTabData) {
- Label tabLabel = (Label)tab.getGraphic();
- WalletIcon walletIcon = (WalletIcon)tabLabel.getGraphic();
+ WalletIcon walletIcon = (WalletIcon)tab.getGraphic();
walletIcon.refresh();
}
}
@@ -2859,8 +2861,7 @@ public void walletAddressesChanged(WalletAddressesChangedEvent event) {
Tab masterTab = subTabs.getTabs().stream().filter(tab -> ((WalletTabData)tab.getUserData()).getWallet().isMasterWallet()).findFirst().orElse(subTabs.getTabs().get(0));
Label masterLabel = (Label)masterTab.getGraphic();
masterLabel.setText(event.getWallet().getLabel() != null ? event.getWallet().getLabel() : event.getWallet().getAutomaticName());
- Label tabLabel = (Label)walletTab.getGraphic();
- WalletIcon walletIcon = (WalletIcon)tabLabel.getGraphic();
+ WalletIcon walletIcon = (WalletIcon)walletTab.getGraphic();
walletIcon.setWallet(event.getWallet());
}
}
@@ -3465,8 +3466,7 @@ public void walletConfigChanged(WalletConfigChangedEvent event) {
for(Tab tab : tabs.getTabs()) {
if(tab.getUserData() instanceof WalletTabData walletTabData) {
if(walletTabData.getWallet() == event.getWallet()) {
- Label tabLabel = (Label)tab.getGraphic();
- WalletIcon walletIcon = (WalletIcon)tabLabel.getGraphic();
+ WalletIcon walletIcon = (WalletIcon)tab.getGraphic();
walletIcon.refresh();
}
}
### src/main/java/com/sparrowwallet/sparrow/event/TabEvent.java
@@ -1,7 +1,6 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.sparrow.TabData;
-import javafx.scene.control.Label;
import javafx.scene.control.Tab;
public class TabEvent {
@@ -16,7 +15,7 @@ public Tab getTab() {
}
public String getTabName() {
- return ((Label)tab.getGraphic()).getText();
+ return tab.getText();
}
public TabData getTabData() {
### src/main/resources/com/sparrowwallet/sparrow/app.css
@@ -35,6 +35,14 @@
-fx-text-fill: rgb(202, 18, 67);
}
+#tabs > .tab-header-area > .headers-region > .tab .tab-label {
+ -fx-graphic-text-gap: 5;
+}
+
+#tabs > .tab-header-area > .headers-region > .long-transaction-tab .tab-label {
+ -fx-pref-width: 300;
+}
+
.tor-status.failure .glyph-font {
-fx-text-fill: rgb(202, 18, 67);
}
@@ -65,6 +73,7 @@
-fx-pref-width: 90;
-fx-alignment: CENTER;
-fx-translate-x: -6;
+ -fx-content-display: graphic-only;
}
.wallet-subtabs > .tab-header-area .tab-label .label {
### src/main/resources/com/sparrowwallet/sparrow/darktheme.css
@@ -165,6 +165,15 @@ HorizontalHeaderColumn > TableColumnHeader.column-header.table-column{
-fx-text-fill: white;
}
+.root #tabs > .tab-header-area > .headers-region > .tab .tab-label {
+ -fx-text-fill: derive(white, -8%);
+}
+
+.root #tabs > .tab-header-area > .headers-region > .tab:selected .tab-label,
+.root #tabs > .tab-header-area > .headers-region > .tab:hover .tab-label {
+ -fx-text-fill: white;
+}
+
.root .wallet-subtabs > .tab-header-area > .headers-region > .tab {
-fx-background-color: derive(#2284bb, 32%);
}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.