Skip to content

Commit

Permalink
Merge pull request #11169 from cetincakiroglu/issue-11168
Browse files Browse the repository at this point in the history
Fixed #11168 - Accessibility | dropdown, button, inputSwitch, calenda…
  • Loading branch information
yigitfindikli authored Feb 15, 2022
2 parents 93df7c3 + 885de3a commit 84c7df5
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const AUTOCOMPLETE_VALUE_ACCESSOR: any = {
template: `
<span #container [ngClass]="{'p-autocomplete p-component':true,'p-autocomplete-dd':dropdown,'p-autocomplete-multiple':multiple}" [ngStyle]="style" [class]="styleClass">
<input *ngIf="!multiple" #in [attr.type]="type" [attr.id]="inputId" [ngStyle]="inputStyle" [class]="inputStyleClass" [autocomplete]="autocomplete" [attr.required]="required" [attr.name]="name"
class="p-autocomplete-input p-inputtext p-component" [ngClass]="{'p-autocomplete-dd-input':dropdown,'p-disabled': disabled}" [value]="inputFieldValue" aria-autocomplete="list" [attr.aria-controls]="listId" role="searchbox" [attr.aria-expanded]="overlayVisible" aria-haspopup="true" [attr.aria-activedescendant]="'p-highlighted-option'"
class="p-autocomplete-input p-inputtext p-component" [ngClass]="{'p-autocomplete-dd-input':dropdown,'p-disabled': disabled}" [value]="inputFieldValue" aria-autocomplete="list" role="searchbox"
(click)="onInputClick($event)" (input)="onInput($event)" (keydown)="onKeydown($event)" (keyup)="onKeyup($event)" [attr.autofocus]="autofocus" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" (change)="onInputChange($event)" (paste)="onInputPaste($event)"
[attr.placeholder]="placeholder" [attr.size]="size" [attr.maxlength]="maxlength" [attr.tabindex]="tabindex" [readonly]="readonly" [disabled]="disabled" [attr.aria-label]="ariaLabel" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-required]="required"
><ul *ngIf="multiple" #multiContainer class="p-autocomplete-multiple-container p-component p-inputtext" [ngClass]="{'p-disabled':disabled,'p-focus':focus}" (click)="multiIn.focus()">
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {
@Component({
selector: 'p-button',
template: `
<button [attr.type]="type" [class]="styleClass" [ngStyle]="style" [disabled]="disabled || loading"
<button [attr.type]="type" [attr.aria-label]="ariaLabel" [class]="styleClass" [ngStyle]="style" [disabled]="disabled || loading"
[ngClass]="{'p-button p-component':true,
'p-button-icon-only': (icon && !label),
'p-button-vertical': (iconPos === 'top' || iconPos === 'bottom') && label,
Expand Down Expand Up @@ -222,6 +222,8 @@ export class Button implements AfterContentInit {

@Input() badgeClass: string;

@Input() ariaLabel: string;

contentTemplate: TemplateRef<any>;

@ContentChildren(PrimeTemplate) templates: QueryList<any>;
Expand Down
10 changes: 6 additions & 4 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export class DropdownItem {
(click)="onMouseclick($event)" [ngStyle]="style" [class]="styleClass">
<div class="p-hidden-accessible">
<input #in [attr.id]="inputId" type="text" readonly (focus)="onInputFocus($event)" aria-haspopup="listbox" [attr.placeholder]="placeholder"
aria-haspopup="listbox" [attr.aria-expanded]="overlayVisible" [attr.aria-labelledby]="ariaLabelledBy" (blur)="onInputBlur($event)" (keydown)="onKeydown($event, true)"
[disabled]="disabled" [attr.tabindex]="tabindex" [attr.autofocus]="autofocus" [attr.aria-activedescendant]="overlayVisible ? 'p-highlighted-option' : labelId" role="listbox">
aria-haspopup="listbox" [attr.aria-label]="ariaLabel" [attr.aria-expanded]="false" [attr.aria-labelledby]="ariaLabelledBy" (blur)="onInputBlur($event)" (keydown)="onKeydown($event, true)"
[disabled]="disabled" [attr.tabindex]="tabindex" [attr.autofocus]="autofocus" [attr.aria-activedescendant]="overlayVisible ? labelId : null" role="combobox">
</div>
<span [attr.id]="labelId" [ngClass]="{'p-dropdown-label p-inputtext':true,'p-dropdown-label-empty':(label == null || label.length === 0)}" *ngIf="!editable && (label != null)" [pTooltip]="tooltip" [tooltipPosition]="tooltipPosition" [positionStyle]="tooltipPositionStyle" [tooltipStyleClass]="tooltipStyleClass">
<ng-container *ngIf="!selectedItemTemplate">{{label||'empty'}}</ng-container>
Expand All @@ -77,12 +77,12 @@ export class DropdownItem {
<input #editableInput type="text" [attr.maxlength]="maxlength" class="p-dropdown-label p-inputtext" *ngIf="editable" [disabled]="disabled" [attr.placeholder]="placeholder"
aria-haspopup="listbox" [attr.aria-expanded]="overlayVisible" (click)="onEditableInputClick()" (input)="onEditableInputChange($event)" (focus)="onEditableInputFocus($event)" (blur)="onInputBlur($event)">
<i class="p-dropdown-clear-icon pi pi-times" (click)="clear($event)" *ngIf="value != null && showClear && !disabled"></i>
<div class="p-dropdown-trigger" role="button" aria-haspopup="listbox" [attr.aria-expanded]="overlayVisible">
<div class="p-dropdown-trigger" role="button" aria-label="dropdown trigger" aria-haspopup="listbox" [attr.aria-expanded]="overlayVisible">
<span class="p-dropdown-trigger-icon" [ngClass]="dropdownIcon"></span>
</div>
<div *ngIf="overlayVisible" [ngClass]="'p-dropdown-panel p-component'" (click)="onOverlayClick($event)" [@overlayAnimation]="{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" (@overlayAnimation.start)="onOverlayAnimationStart($event)" (@overlayAnimation.start)="onOverlayAnimationEnd($event)"onOverlayAnimationEnd [ngStyle]="panelStyle" [class]="panelStyleClass">
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
<div class="p-dropdown-header" *ngIf="filter" >
<div class="p-dropdown-header" *ngIf="filter">
<div class="p-dropdown-filter-container" (click)="$event.stopPropagation()">
<input #filter type="text" autocomplete="off" [value]="filterValue||''" class="p-dropdown-filter p-inputtext p-component" [attr.placeholder]="filterPlaceholder"
(keydown.enter)="$event.preventDefault()" (keydown)="onKeydown($event, false)" (input)="onFilterInputChange($event)" [attr.aria-label]="ariaFilterLabel" [attr.aria-activedescendant]="overlayVisible ? 'p-highlighted-option' : labelId">
Expand Down Expand Up @@ -240,6 +240,8 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView

@Input() ariaFilterLabel: string;

@Input() ariaLabel: string;

@Input() ariaLabelledBy: string;

@Input() filterMatchMode: string = "contains";
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/inputnumber/inputnumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const INPUTNUMBER_VALUE_ACCESSOR: any = {
[ngStyle]="style" [class]="styleClass">
<input #input [ngClass]="'p-inputnumber-input'" [ngStyle]="inputStyle" [class]="inputStyleClass" pInputText [value]="formattedValue()" [attr.placeholder]="placeholder" [attr.title]="title" [attr.id]="inputId"
[attr.size]="size" [attr.name]="name" [attr.autocomplete]="autocomplete" [attr.maxlength]="maxlength" [attr.tabindex]="tabindex" [attr.aria-label]="ariaLabel"
[attr.aria-required]="ariaRequired" [disabled]="disabled" [attr.required]="required" [attr.aria-valuemin]="min" [attr.aria-valuemax]="max" [readonly]="readonly" inputmode="decimal"
[attr.aria-required]="ariaRequired" [disabled]="disabled" [attr.required]="required" [attr.min]="min" [attr.max]="max" [readonly]="readonly" inputmode="decimal"
(input)="onUserInput($event)" (keydown)="onInputKeyDown($event)" (keypress)="onInputKeyPress($event)" (paste)="onPaste($event)" (click)="onInputClick()"
(focus)="onInputFocus($event)" (blur)="onInputBlur($event)">
<span class="p-inputnumber-button-group" *ngIf="showButtons && buttonLayout === 'stacked'">
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/inputswitch/inputswitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const INPUTSWITCH_VALUE_ACCESSOR: any = {
<div [ngClass]="{'p-inputswitch p-component': true, 'p-inputswitch-checked': checked(), 'p-disabled': disabled, 'p-focus': focused}"
[ngStyle]="style" [class]="styleClass" (click)="onClick($event, cb)">
<div class="p-hidden-accessible">
<input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [attr.tabindex]="tabindex" [checked]="checked()" (change)="onInputChange($event)"
<input #cb type="checkbox" [attr.aria-label]="ariaLabel" [attr.id]="inputId" [attr.name]="name" [attr.tabindex]="tabindex" [checked]="checked()" (change)="onInputChange($event)"
(focus)="onFocus($event)" (blur)="onBlur($event)" [disabled]="disabled" role="switch" [attr.aria-checked]="checked()" [attr.aria-labelledby]="ariaLabelledBy"/>
</div>
<span class="p-inputswitch-slider"></span>
Expand Down Expand Up @@ -48,6 +48,8 @@ export class InputSwitch implements ControlValueAccessor {

@Input() falseValue: any = false;

@Input() ariaLabel:string;

@Input() ariaLabelledBy: string;

@Output() onChange: EventEmitter<any> = new EventEmitter();
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/panel/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ let idx: number = 0;
<span class="p-panel-title" *ngIf="header" [attr.id]="id + '_header'">{{header}}</span>
<ng-content select="p-header"></ng-content>
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
<div class="p-panel-icons">
<div class="p-panel-icons" role="tablist">
<ng-template *ngTemplateOutlet="iconTemplate"></ng-template>
<button *ngIf="toggleable" type="button" [attr.id]="id + '-label'" class="p-panel-header-icon p-panel-toggler p-link" pRipple
<button *ngIf="toggleable" type="button" [attr.aria-label]="'collapse button'" [attr.id]="id + '-label'" class="p-panel-header-icon p-panel-toggler p-link" pRipple
(click)="onIconClick($event)" (keydown.enter)="onIconClick($event)" [attr.aria-controls]="id + '-content'" role="tab" [attr.aria-expanded]="!collapsed">
<span [class]="collapsed ? expandIcon : collapseIcon"></span>
</button>
Expand Down
6 changes: 6 additions & 0 deletions src/app/showcase/components/button/buttondemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ <h5>Properties of p-button</h5>
<td>null</td>
<td>Callback to execute when button loses focus.</td>
</tr>
<tr>
<td>ariaLabel</td>
<td>string</td>
<td>null</td>
<td>Used to define a string that autocomplete attribute the current element.</td>
</tr>
</tbody>
</table>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/app/showcase/components/dropdown/dropdowndemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ <h5>Properties</h5>
<td>null</td>
<td>Defines a string that labels the filter input.</td>
</tr>
<tr>
<td>ariaLabel</td>
<td>string</td>
<td>null</td>
<td>Used to define a string that autocomplete attribute the current element.</td>
</tr>
<tr>
<td>tooltip</td>
<td>any</td>
Expand Down
6 changes: 6 additions & 0 deletions src/app/showcase/components/inputswitch/inputswitchdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ <h5>Properties</h5>
<td>null</td>
<td>Value in unchecked state.</td>
</tr>
<tr>
<td>ariaLabel</td>
<td>string</td>
<td>null</td>
<td>Used to define a string that autocomplete attribute the current element.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 84c7df5

Please sign in to comment.