luci-base: fix label association warning for Dropdown widget#8382
Open
stangri wants to merge 1 commit intoopenwrt:masterfrom
Open
luci-base: fix label association warning for Dropdown widget#8382stangri wants to merge 1 commit intoopenwrt:masterfrom
stangri wants to merge 1 commit intoopenwrt:masterfrom
Conversation
The Dropdown widget renders as a <div>, which is not a labelable HTML element. When used with MultiValue or other dropdown-based form options, the browser console shows "label's for attribute doesn't match any element id" because renderFrame() creates a <label for="widget.cbid..."> but no element with that id or data-widget-id exists in the Dropdown. Add data-widget-id attribute to the Dropdown container, matching the pattern already used by Checkbox (ui.js line 647). This allows renderFrame()'s existing fallback selector (form.js line 4454) to find the widget element, resolving the browser accessibility warning. Signed-off-by: Stan Grishin <stangri@melmac.ca>
Failed checksIssues marked with an ❌ are failing checks. Commit 9c347df
For more details, see the full job log. Something broken? Consider providing feedback. |
Contributor
|
A bit of a can of worms here. I can only reproduce this on Chrome which generates those notices, and I cannot seem to silence the notice with this change alone. The checkboxes which use 'label' for the text label (also) generate the notice. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
data-widget-idattribute to the Dropdown widget's container<div>, matching the pattern already used by Checkbox (ui.jsline 647)renderFrame()'s existing fallback selector (form.jsline 4454) to find the widget, resolving browser console accessibility warningsProblem
The Dropdown widget renders as a
<div>, which is not a labelable HTML element. When used withMultiValueor other dropdown-based form options,renderFrame()creates a<label for="widget.cbid...">but no element with thatidordata-widget-idexists in the Dropdown output.This causes browser DevTools to report:
<label>element with aforattribute doesn't match any element id"Fix
Single-line addition — add
data-widget-idtoUIDropdown.render():This leverages the existing fallback mechanism in
renderFrame():Test plan
MultiValuewidget (e.g., any app with a multi-select dropdown)🤖 Generated with Claude Code