Skip to content

Commit

Permalink
fix: editable input have unique id for aria-labelledby (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Kang authored Jun 10, 2021
1 parent 257d273 commit 3f919b6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/common/editable-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {

import { fromEvent, Subscription } from 'rxjs';

let nextUniqueId = 0;

@Component({
selector: 'color-editable-input',
template: `
Expand All @@ -26,9 +28,9 @@ import { fromEvent, Subscription } from 'rxjs';
(keyup)="handleKeyup($event)"
(focus)="handleFocus($event)"
(focusout)="handleFocusOut($event)"
aria-labelledby="colorEditableInputLabel"
[attr.aria-labelledby]="uniqueId"
/>
<span id="colorEditableInputLabel" *ngIf="label" [ngStyle]="labelStyle" (mousedown)="handleMousedown($event)">
<span [id]="uniqueId" *ngIf="label" [ngStyle]="labelStyle" (mousedown)="handleMousedown($event)">
{{ label }}
</span>
</div>
Expand Down Expand Up @@ -66,6 +68,7 @@ export class EditableInputComponent implements OnInit, OnChanges, OnDestroy {
focus = false;
mousemove!: Subscription;
mouseup!: Subscription;
uniqueId: string = `editableInput-${++nextUniqueId}`;

ngOnInit() {
this.wrapStyle = this.style && this.style.wrap ? this.style.wrap : {};
Expand Down

0 comments on commit 3f919b6

Please sign in to comment.