提交 47402135 编写于 作者: I isidor

list: improve aria-selected to be set on each selected element. Set...

list: improve aria-selected to be set on each selected element. Set aria-multiselectable when mutli selct is supported
上级 43f8140f
......@@ -180,10 +180,10 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
}
}
class FocusTrait<T> extends Trait<T> {
class SelectionTrait<T> extends Trait<T> {
constructor() {
super('focused');
super('selected');
}
renderIndex(index: number, container: HTMLElement): void {
......@@ -1198,8 +1198,8 @@ export class List<T> implements ISpliceable<T>, IDisposable {
renderers: IListRenderer<any /* TODO@joao */, any>[],
private _options: IListOptions<T> = DefaultOptions
) {
this.focus = new FocusTrait();
this.selection = new Trait('selected');
this.focus = new Trait('focused');
this.selection = new SelectionTrait();
mixin(_options, defaultStyles, false);
......@@ -1272,6 +1272,9 @@ export class List<T> implements ISpliceable<T>, IDisposable {
if (_options.ariaLabel) {
this.view.domNode.setAttribute('aria-label', localize('aria list', "{0}. Use the navigation keys to navigate.", _options.ariaLabel));
}
if (_options.multipleSelectionSupport) {
this.view.domNode.setAttribute('aria-multiselectable', 'true');
}
}
protected createMouseController(options: IListOptions<T>): MouseController<T> {
......
......@@ -218,13 +218,15 @@ export class ViewItem implements IViewItem {
}
if (this.model.hasTrait('focused')) {
const base64Id = strings.safeBtoa(this.model.id);
this.element.setAttribute('aria-selected', 'true');
this.element.setAttribute('id', base64Id);
} else {
this.element.setAttribute('aria-selected', 'false');
this.element.removeAttribute('id');
}
if (this.model.hasTrait('selected')) {
this.element.setAttribute('aria-selected', 'true');
} else {
this.element.setAttribute('aria-selected', 'false');
}
if (this.model.hasChildren()) {
this.element.setAttribute('aria-expanded', String(!!this._styles['expanded']));
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册