Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: A11Y Dropdpwn + Icons #7269

Merged
merged 5 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
(change)="inputChange($event)" (blur)="blur($event)" (focus)="focus($event)"/>
</div>
<div *ngIf="(model.allowClear && model.cssClasses.cleanButtonIconId)"
[class]="model.cssClasses.cleanButton" (click)="clear($event)" [visible]="model.showClearButton">
[class]="model.cssClasses.cleanButton" (click)="clear($event)" [visible]="model.showClearButton" [attr.tabindex]="model.inputReadOnly ? -1 : 0">
<!-- ko component: { name: 'sv-svg-icon', params: { css: model.cssClasses.cleanButtonSvg, iconName: model.cssClasses.cleanButtonIconId, size: 'auto' } } -->
<!-- /ko -->
<svg [iconName]="model.cssClasses.cleanButtonIconId" [partCss]="model.cssClasses.cleanButtonSvg" [title]="model.clearCaption"
Expand All @@ -46,7 +46,7 @@
<sv-ng-string *ngIf="model.selectedItemLocText" [model]="model.selectedItemLocText"></sv-ng-string>
<div>{{ model.readOnlyText }}</div>
</div>
<div *ngIf="model.cssClasses.chevronButtonIconId" [class]="model.cssClasses.chevronButton" (pointerdown)="chevronPointerDown($event)">
<div *ngIf="model.cssClasses.chevronButtonIconId" [class]="model.cssClasses.chevronButton" (pointerdown)="chevronPointerDown($event)" aria-hidden="true">
<svg [iconName]="model.cssClasses.chevronButtonIconId" [partCss]="model.cssClasses.chevronButtonSvg" [size]="'auto'" sv-ng-svg-icon></svg>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ export class SvgIconComponent implements OnChanges {
@HostBinding("[attr.role]") get rootRole(): string {
return "img";
}
@HostBinding("[attr.aria-label]") get ariaLabel(): string {
return <string>this.title;
}
ngOnChanges(): void {
const el = this.viewContaierRef.element.nativeElement;
el.innerHTML = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ng-container>
<ng-template [component]="{ name: 'sv-tagbox-filter', data: { model: dropdownModel, question: model } }"></ng-template>
</div>
<div *ngIf="(model.allowClear && model.cssClasses.cleanButtonIconId)" [class]="model.cssClasses.cleanButton"
<div *ngIf="(model.allowClear && model.cssClasses.cleanButtonIconId)" [class]="model.cssClasses.cleanButton" [attr.tabindex]="model.inputReadOnly ? -1 : 0"
(click)="clear($event)" [visible]="model.showClearButton">
<!-- ko component: { name: 'sv-svg-icon', params: { css: model.cssClasses.cleanButtonSvg, iconName: model.cssClasses.cleanButtonIconId, size: 'auto' } } -->
<!-- /ko -->
Expand Down
2 changes: 2 additions & 0 deletions packages/survey-vue3-ui/src/components/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
v-if="question.allowClear && question.cssClasses.cleanButtonIconId"
v-show="question.showClearButton"
@click="clear"
:tabindex="question.inputReadOnly ? -1 : 0"
>
<sv-svg-icon
:class="question.cssClasses.cleanButtonSvg"
Expand Down Expand Up @@ -108,6 +109,7 @@
:class="question.cssClasses.chevronButton"
v-on:pointerdown="chevronPointerDown"
v-if="question.cssClasses.chevronButtonIconId"
aria-hidden="true"
>
<sv-svg-icon
:class="question.cssClasses.chevronButtonSvg"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<svg ref="svgIconElement" class="sv-svg-icon" role="img" :aria-label="title">
<svg ref="svgIconElement" class="sv-svg-icon" role="img">
<use></use>
</svg>
</template>
Expand Down
1 change: 1 addition & 0 deletions packages/survey-vue3-ui/src/components/tagbox/Tagbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
v-if="question.allowClear && question.cssClasses.cleanButtonIconId"
v-show="question.showClearButton"
@click="clear"
:tabindex="question.inputReadOnly ? -1 : 0"
>
<sv-svg-icon
:class="question.cssClasses.cleanButtonSvg"
Expand Down
4 changes: 2 additions & 2 deletions src/knockout/components/dropdown/dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
event: { blur: blur, focus: focus }"></input>
</div>
<!-- ko if: (question.allowClear && question.cssClasses.cleanButtonIconId) -->
<div data-bind="css: question.cssClasses.cleanButton, click: clear, visible: question.showClearButton ">
<div data-bind="css: question.cssClasses.cleanButton, click: clear, visible: question.showClearButton, attr: {tabindex: question.inputReadOnly ? -1 : 0}">
<!-- ko component: { name: 'sv-svg-icon', params: { css: question.cssClasses.cleanButtonSvg, iconName: question.cssClasses.cleanButtonIconId, size: 'auto', title: question.clearCaption } } -->
<!-- /ko -->
</div>
Expand All @@ -75,7 +75,7 @@
</div>
<!-- /ko -->
<!-- ko if: question.cssClasses.chevronButtonIconId -->
<div data-bind="css: question.cssClasses.chevronButton, event: {pointerdown: chevronPointerDown}">
<div data-bind="css: question.cssClasses.chevronButton, event: {pointerdown: chevronPointerDown}" aria-hidden="true">
<!-- ko component: { name: 'sv-svg-icon', params: { css: question.cssClasses.chevronButtonSvg, iconName: question.cssClasses.chevronButtonIconId, size: 'auto' } } -->
<!-- /ko -->
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/knockout/components/svg-icon/svg-icon.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- ko if: hasIcon -->
<svg class="sv-svg-icon" data-bind="css: css, attr: { 'aria-label': title }" role="img"><use></use></svg>
<svg class="sv-svg-icon" data-bind="css: css" role="img"><use></use></svg>
<!-- /ko -->
2 changes: 1 addition & 1 deletion src/knockout/components/tagbox/tagbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>
</div>
<!-- ko if: (question.allowClear && question.cssClasses.cleanButtonIconId) -->
<div data-bind="css: question.cssClasses.cleanButton, click: clear, visible: question.showClearButton ">
<div data-bind="css: question.cssClasses.cleanButton, click: clear, visible: question.showClearButton, attr: {tabindex: question.inputReadOnly ? -1 : 0} ">
<!-- ko component: { name: 'sv-svg-icon', params: { css: question.cssClasses.cleanButtonSvg, iconName: question.cssClasses.cleanButtonIconId, size: 'auto', title: question.clearCaption } } -->
<!-- /ko -->
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/svg-icon/svg-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class SvgIcon extends React.Component<any, any> {
}
return (
this.props.iconName ?
<svg className={ className } style={this.props.style} onClick={this.props.onClick} ref={this.svgIconRef} role="img" aria-label={this.props.title}><use></use></svg>
<svg className={ className } style={this.props.style} onClick={this.props.onClick} ref={this.svgIconRef} role="img"><use></use></svg>
: null
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/react/dropdown-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class SurveyQuestionDropdownBase<T extends Question> extends SurveyQuesti
className={this.question.cssClasses.cleanButton}
style={style}
onClick={this.clear}
tabIndex={this.question.inputReadOnly ? -1 : 0}
>
<SvgIcon
className={this.question.cssClasses.cleanButtonSvg}
Expand All @@ -162,6 +163,7 @@ export class SurveyQuestionDropdownBase<T extends Question> extends SurveyQuesti

return (
<div className={this.question.cssClasses.chevronButton}
aria-hidden="true"
onPointerDown={this.chevronPointerDown}>
<SvgIcon
className={this.question.cssClasses.chevronButtonSvg}
Expand Down
2 changes: 2 additions & 0 deletions src/vue/components/dropdown/dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
v-if="question.allowClear && question.cssClasses.cleanButtonIconId"
v-show="question.showClearButton"
@click="clear"
:tabindex="question.inputReadOnly ? -1 : 0"
>
<sv-svg-icon
:class="question.cssClasses.cleanButtonSvg"
Expand All @@ -90,6 +91,7 @@
:class="question.cssClasses.chevronButton"
v-on:pointerdown="chevronPointerDown"
v-if="question.cssClasses.chevronButtonIconId"
aria-hidden="true"
>
<sv-svg-icon
:class="question.cssClasses.chevronButtonSvg"
Expand Down
2 changes: 1 addition & 1 deletion src/vue/components/svg-icon/svg-icon.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<svg ref="svgIcon" class="sv-svg-icon" role="img" :aria-label="title"><use></use></svg>
<svg ref="svgIcon" class="sv-svg-icon" role="img"><use></use></svg>
</template>

<script lang="ts">
Expand Down
1 change: 1 addition & 0 deletions src/vue/components/tagbox/tagbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
v-if="question.allowClear && question.cssClasses.cleanButtonIconId"
v-show="question.showClearButton"
@click="clear"
:tabindex="question.inputReadOnly ? -1 : 0"
>
<sv-svg-icon
:class="question.cssClasses.cleanButtonSvg"
Expand Down
2 changes: 2 additions & 0 deletions testCafe/questions/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ frameworks.forEach((framework) => {
.expect(popupContainer.visible).notOk()
.expect(questionValueInput.value).eql("Volkswagen")

.pressKey("tab")
.pressKey("tab")
.pressKey("2")
.pressKey("down")
Expand Down Expand Up @@ -849,6 +850,7 @@ frameworks.forEach((framework) => {
.expect(popupContainer.visible).notOk()
.expect(questionValueText.textContent).eql("Volkswagen")

.pressKey("tab")
.pressKey("tab")
.pressKey("down")
.pressKey("down")
Expand Down
4 changes: 2 additions & 2 deletions tests/markup/snapshots/dropdown-aria-expanded.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<div class="sv_q_dropdown__value">
<input aria-controls="testid0i_list" aria-expanded="true" aria-label="Question title" autocomplete="off" class="sv_q_dropdown__filter-string-input" id="testid0i_0" inputmode="text" placeholder="Select..." role="combobox" type="text">
</div>
<div class="sv_q_dropdown_clean-button" style="display:none;">
<svg aria-label="Clear" class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<div class="sv_q_dropdown_clean-button" style="display:none;" tabindex="0">
<svg class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<use xlink:href="#icon-clear_16x16" class="">
</use>
<title class="">Clear</title>
Expand Down
4 changes: 2 additions & 2 deletions tests/markup/snapshots/dropdown-input-string.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</div>
<input aria-controls="testid0i_list" aria-expanded="true" aria-label="Question title" autocomplete="off" class="sv_q_dropdown__filter-string-input" inputmode="text" placeholder="" role="combobox" type="text">
</div>
<div class="sv_q_dropdown_clean-button" style="display:none;">
<svg aria-label="Clear" class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<div class="sv_q_dropdown_clean-button" style="display:none;" tabindex="0">
<svg class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<use xlink:href="#icon-clear_16x16" class="">
</use>
<title class="">Clear</title>
Expand Down
4 changes: 2 additions & 2 deletions tests/markup/snapshots/dropdown-select-clear-button.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<span class="sv-string-viewer">item1</span>
<input aria-controls="testid0i_list" aria-expanded="false" aria-label="Question title" autocomplete="off" class="sv_q_dropdown__filter-string-input" id="testid0i_0" inputmode="text" placeholder="" role="combobox" type="text">
</div>
<div class="sv_q_dropdown_clean-button">
<svg aria-label="Clear" class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<div class="sv_q_dropdown_clean-button" tabindex="0">
<svg class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<use xlink:href="#icon-clear_16x16" class="">
</use>
<title class="">Clear</title>
Expand Down
4 changes: 2 additions & 2 deletions tests/markup/snapshots/dropdown-with-markdown.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<span class="sv-string-viewer">Cat: ![A cat](https://surveyjs.io/Content/Images/examples/markdown/cat.svg =14x14)</span>
<input aria-controls="testid0i_list" aria-expanded="false" aria-label="Question title" autocomplete="off" class="sv_q_dropdown__filter-string-input" id="testid0i_0" inputmode="text" placeholder="" role="combobox" type="text">
</div>
<div class="sv_q_dropdown_clean-button">
<svg aria-label="Clear" class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<div class="sv_q_dropdown_clean-button" tabindex="0">
<svg class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<use xlink:href="#icon-clear_16x16" class="">
</use>
<title class="">Clear</title>
Expand Down
4 changes: 2 additions & 2 deletions tests/markup/snapshots/dropdown-with-none-value.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<span class="sv-string-viewer">None</span>
<input aria-controls="testid0i_list" aria-expanded="false" aria-label="Question title" autocomplete="off" class="sv_q_dropdown__filter-string-input" id="testid0i_0" inputmode="text" placeholder="" role="combobox" type="text">
</div>
<div class="sv_q_dropdown_clean-button">
<svg aria-label="Clear" class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<div class="sv_q_dropdown_clean-button" tabindex="0">
<svg class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<use xlink:href="#icon-clear_16x16" class="">
</use>
<title class="">Clear</title>
Expand Down
4 changes: 2 additions & 2 deletions tests/markup/snapshots/dropdown-with-other-value.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<span class="sv-string-viewer">Other (describe)</span>
<input aria-controls="testid0i_list" aria-expanded="false" aria-label="Question title" autocomplete="off" class="sv_q_dropdown__filter-string-input" id="testid0i_0" inputmode="text" placeholder="" role="combobox" type="text">
</div>
<div class="sv_q_dropdown_clean-button">
<svg aria-label="Clear" class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<div class="sv_q_dropdown_clean-button" tabindex="0">
<svg class="sv_q_dropdown_clean-button-svg sv-svg-icon" role="img">
<use xlink:href="#icon-clear_16x16" class="">
</use>
<title class="">Clear</title>
Expand Down
8 changes: 4 additions & 4 deletions tests/markup/snapshots/file-2-png.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="sv-action" id="sv-file-choose-file">
<div class="sv-action__content">
<label aria-label="Replace file" class="sd-context-btn sd-file__choose-btn sd-file__choose-btn--icon" for="testid0i" tabindex="0">
<svg aria-label="Replace file" class="sv-svg-icon" role="img">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-choosefile" class="">
</use>
<title class="">Replace file</title>
Expand All @@ -22,7 +22,7 @@
<div class="sv-action sv-action--hidden" id="sv-file-start-camera">
<div class="sv-action__content">
<button class="sd-context-btn" role="button" tabindex="0" title="Take Photo" type="button">
<svg aria-label="Take Photo" class="sd-action__icon sv-svg-icon" role="img">
<svg class="sd-action__icon sv-svg-icon" role="img">
<use xlink:href="#icon-takepicture_24x24" class="">
</use>
<title class="">Take Photo</title>
Expand All @@ -33,7 +33,7 @@
<div class="sv-action" id="sv-file-clean">
<div class="sv-action__content">
<button class="sd-context-btn sd-context-btn--negative" role="button" tabindex="0" title="Clear" type="button">
<svg aria-label="Clear" class="sd-action__icon sv-svg-icon" role="img">
<svg class="sd-action__icon sv-svg-icon" role="img">
<use xlink:href="#icon-clear" class="">
</use>
<title class="">Clear</title>
Expand All @@ -50,7 +50,7 @@
<img alt="File preview" src="#item1.png">
<div class="sd-context-btn sd-context-btn--negative sd-file__remove-file-button">
<span class="sd-hidden">Remove this file</span>
<svg aria-label="Remove this file" class="sv-svg-icon" role="img">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-delete" class="">
</use>
<title class="">Remove this file</title>
Expand Down
10 changes: 5 additions & 5 deletions tests/markup/snapshots/file-2-zip-png-file-navigator.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="sv-action" id="sv-file-choose-file">
<div class="sv-action__content">
<label aria-label="Select File" class="sd-context-btn sd-file__choose-btn sd-file__choose-btn--icon" for="testid0i" tabindex="0">
<svg aria-label="Select File" class="sv-svg-icon" role="img">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-choosefile" class="">
</use>
<title class="">Select File</title>
Expand All @@ -22,7 +22,7 @@
<div class="sv-action sv-action--hidden" id="sv-file-start-camera">
<div class="sv-action__content">
<button class="sd-context-btn" role="button" tabindex="0" title="Take Photo" type="button">
<svg aria-label="Take Photo" class="sd-action__icon sv-svg-icon" role="img">
<svg class="sd-action__icon sv-svg-icon" role="img">
<use xlink:href="#icon-takepicture_24x24" class="">
</use>
<title class="">Take Photo</title>
Expand All @@ -33,7 +33,7 @@
<div class="sv-action" id="sv-file-clean">
<div class="sv-action__content">
<button class="sd-context-btn sd-context-btn--negative" role="button" tabindex="0" title="Clear" type="button">
<svg aria-label="Clear" class="sd-action__icon sv-svg-icon" role="img">
<svg class="sd-action__icon sv-svg-icon" role="img">
<use xlink:href="#icon-clear" class="">
</use>
<title class="">Clear</title>
Expand All @@ -53,7 +53,7 @@
</svg>
<div class="sd-context-btn sd-context-btn--negative sd-file__remove-file-button">
<span class="sd-hidden">Remove this file</span>
<svg aria-label="Remove this file" class="sv-svg-icon" role="img">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-delete" class="">
</use>
<title class="">Remove this file</title>
Expand All @@ -69,7 +69,7 @@
<img alt="File preview" src="#item2.png">
<div class="sd-context-btn sd-context-btn--negative sd-file__remove-file-button">
<span class="sd-hidden">Remove this file</span>
<svg aria-label="Remove this file" class="sv-svg-icon" role="img">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-delete" class="">
</use>
<title class="">Remove this file</title>
Expand Down
6 changes: 3 additions & 3 deletions tests/markup/snapshots/file-2-zip-png-ro.snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="sv-action" id="sv-file-choose-file">
<div class="sv-action__content">
<label aria-label="Select File" class="sd-context-btn sd-file__choose-btn sd-file__choose-btn--icon" for="testid0i" tabindex="0">
<svg aria-label="Select File" class="sv-svg-icon" role="img">
<svg class="sv-svg-icon" role="img">
<use xlink:href="#icon-choosefile" class="">
</use>
<title class="">Select File</title>
Expand All @@ -22,7 +22,7 @@
<div class="sv-action sv-action--hidden" id="sv-file-start-camera">
<div class="sv-action__content">
<button class="sd-context-btn" disabled="" role="button" tabindex="0" title="Take Photo" type="button">
<svg aria-label="Take Photo" class="sd-action__icon sv-svg-icon" role="img">
<svg class="sd-action__icon sv-svg-icon" role="img">
<use xlink:href="#icon-takepicture_24x24" class="">
</use>
<title class="">Take Photo</title>
Expand All @@ -33,7 +33,7 @@
<div class="sv-action" id="sv-file-clean">
<div class="sv-action__content">
<button class="sd-context-btn sd-context-btn--negative" disabled="" role="button" tabindex="0" title="Clear" type="button">
<svg aria-label="Clear" class="sd-action__icon sv-svg-icon" role="img">
<svg class="sd-action__icon sv-svg-icon" role="img">
<use xlink:href="#icon-clear" class="">
</use>
<title class="">Clear</title>
Expand Down
Loading