-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(chips): use built-in radiogroup / checkbox behavior for a11y (#890)
* fix(chips): add focus styles, make input focusable & expose label * chore(chips): remove html lint ignores, add label for single-chip entry in patternlab * Update chip.scss --------- Co-authored-by: Maximilian Franzke <[email protected]>
- Loading branch information
1 parent
4276aac
commit 90be16a
Showing
3 changed files
with
21 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,29 @@ | ||
{{! TODO: This would need to get enhanced later on by the additional possible attributes }} | ||
{{#if selection}} | ||
<!-- [html-validate-disable-next input-missing-label -- label get read out on the input field already and could get aria hidden] --> | ||
<input | ||
class="elm-chip" | ||
type="radio" | ||
id="chip-single-{{ variant }}{{ id-suffix }}" | ||
name="{{ name }}" | ||
data-type="selection" | ||
{{#if disabled }} disabled{{/if }}> | ||
<!-- [html-validate-disable-next prefer-native-element -- TODO: Evaluate again on this HTML] --> | ||
<label | ||
for="chip-single-{{ variant }}{{ id-suffix }}" | ||
role="button" | ||
{{#if variant }} data-variant="{{ variant }}"{{/if }} | ||
{{#if icon }} data-icon="{{ icon }}"{{/if }} | ||
{{#if iconAfter }} data-icon-after="{{ iconAfter }}"{{/if }} | ||
tabindex="0" | ||
aria-hidden="true" | ||
>{{ label }}</label> | ||
{{else}} | ||
<!-- [html-validate-disable-next input-missing-label -- label get read out on the input field already and could get aria hidden] --> | ||
<input | ||
class="elm-chip" | ||
type="checkbox" | ||
id="chip-multiple-{{ variant }}{{ id-suffix }}" | ||
id="chip-multiple{{#if disabled }}-disabled{{/if}}-{{ variant }}{{ id-suffix }}" | ||
data-type="filter" | ||
{{#if disabled }} disabled{{/if }}> | ||
<!-- [html-validate-disable-next prefer-native-element -- TODO: Evaluate again on this HTML] --> | ||
<label | ||
for="chip-multiple-{{ variant }}{{ id-suffix }}" | ||
role="button" | ||
for="chip-multiple{{#if disabled }}-disabled{{/if}}-{{ variant }}{{ id-suffix }}" | ||
{{#if variant }} data-variant="{{ variant }}"{{/if }} | ||
{{#if icon }} data-icon="{{ icon }}"{{/if }} | ||
{{#if iconAfter }} data-icon-after="{{ iconAfter }}"{{/if }} | ||
tabindex="0" | ||
aria-hidden="true" | ||
>{{ label }}</label> | ||
{{/if }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"label": "Title" | ||
} |
This file contains 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