]> git.joonet.de Git - adminer.git/commitdiff
Accessibility: Use <option>(label) as label
authorJakub Vrana <jakub@vrana.cz>
Mon, 7 Apr 2025 09:43:52 +0000 (11:43 +0200)
committerJakub Vrana <jakub@vrana.cz>
Mon, 7 Apr 2025 09:43:52 +0000 (11:43 +0200)
adminer/include/html.inc.php

index 9193b5d5ba5c8e443256f2af49ede5c5111bf057..91ce6cd8754d4ea9ce495735010ca4b00f11fb5c 100644 (file)
@@ -90,9 +90,17 @@ function optionlist($options, $selected = null, bool $use_keys = false): string
 * @param string[] $options
 */
 function html_select(string $name, array $options, ?string $value = "", string $onchange = "", string $labelled_by = ""): string {
+       static $label = 0;
+       $label_option = "";
+       if (!$labelled_by && substr($options[""], 0, 1) == "(") {
+               $label++;
+               $labelled_by = "label-$label";
+               $label_option = "<option value='' id='$labelled_by'>" . h($options[""]);
+               unset($options[""]);
+       }
        return "<select name='" . h($name) . "'"
                . ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
-               . ">" . optionlist($options, $value) . "</select>"
+               . ">" . $label_option . optionlist($options, $value) . "</select>"
                . ($onchange ? script("qsl('select').onchange = function () { $onchange };", "") : "")
        ;
 }