mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Default checkbox aria label to label (#8367)
This commit is contained in:
@@ -30,15 +30,15 @@ export class Checkbox extends Widget {
|
|||||||
private _onChange = new Emitter<boolean>();
|
private _onChange = new Emitter<boolean>();
|
||||||
public readonly onChange: Event<boolean> = this._onChange.event;
|
public readonly onChange: Event<boolean> = this._onChange.event;
|
||||||
|
|
||||||
constructor(container: HTMLElement, opts: ICheckboxOptions) {
|
constructor(container: HTMLElement, private _opts: ICheckboxOptions) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this._el = document.createElement('input');
|
this._el = document.createElement('input');
|
||||||
this._el.type = 'checkbox';
|
this._el.type = 'checkbox';
|
||||||
this._el.style.verticalAlign = 'middle';
|
this._el.style.verticalAlign = 'middle';
|
||||||
|
|
||||||
if (opts.ariaLabel) {
|
if (_opts.ariaLabel) {
|
||||||
this._el.setAttribute('aria-label', opts.ariaLabel);
|
this._el.setAttribute('aria-label', _opts.ariaLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onchange(this._el, e => {
|
this.onchange(this._el, e => {
|
||||||
@@ -55,12 +55,12 @@ export class Checkbox extends Widget {
|
|||||||
this._label = document.createElement('span');
|
this._label = document.createElement('span');
|
||||||
this._label.style.verticalAlign = 'middle';
|
this._label.style.verticalAlign = 'middle';
|
||||||
|
|
||||||
this.label = opts.label;
|
this.label = _opts.label;
|
||||||
this.enabled = opts.enabled || true;
|
this.enabled = _opts.enabled || true;
|
||||||
this.checked = opts.checked || false;
|
this.checked = _opts.checked || false;
|
||||||
|
|
||||||
if (opts.onChange) {
|
if (_opts.onChange) {
|
||||||
this.onChange(opts.onChange);
|
this.onChange(_opts.onChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.appendChild(this._el);
|
container.appendChild(this._el);
|
||||||
@@ -69,6 +69,10 @@ export class Checkbox extends Widget {
|
|||||||
|
|
||||||
public set label(val: string) {
|
public set label(val: string) {
|
||||||
this._label.innerText = val;
|
this._label.innerText = val;
|
||||||
|
// Default the aria label to the label if one wasn't specifically set by the user
|
||||||
|
if (!this._opts.ariaLabel) {
|
||||||
|
this._el.setAttribute('aria-label', val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public set enabled(val: boolean) {
|
public set enabled(val: boolean) {
|
||||||
|
|||||||
Reference in New Issue
Block a user