From 83a88100034063856a87b2ac3c3497e49f074cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 13 Nov 2024 00:51:22 +0100 Subject: [PATCH] status/backlight: Fix a11y label of discrete level buttons Point the discrete level buttons to the corresponding labels, so that they don't appear as plain "button" in screen readers. Part-of: --- js/ui/status/backlight.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/ui/status/backlight.js b/js/ui/status/backlight.js index b39cfa632..d43e1ee45 100644 --- a/js/ui/status/backlight.js +++ b/js/ui/status/backlight.js @@ -106,17 +106,23 @@ const DiscreteItem = GObject.registerClass({ return 100 * Math.min(keyIndex, this.nLevels - 1) / (this.nLevels - 1); } - _addLevelButton(key, label, iconName) { + _addLevelButton(key, labelText, iconName) { const box = new St.BoxLayout({ style_class: 'keyboard-brightness-level', vertical: true, x_expand: true, }); + const label = new St.Label({ + text: labelText, + x_align: Clutter.ActorAlign.CENTER, + }); + box.button = new St.Button({ styleClass: 'icon-button', canFocus: true, iconName, + labelActor: label, }); box.add_child(box.button); @@ -124,10 +130,7 @@ const DiscreteItem = GObject.registerClass({ this.value = this._levelToValue(key); }); - box.add_child(new St.Label({ - text: label, - x_align: Clutter.ActorAlign.CENTER, - })); + box.add_child(label); this.add_child(box); this._levelButtons.set(key, box);