Skip to content

Commit e9c5dce

Browse files
authored
Merge pull request #149 from marthacryan/checkbox
Add checkbox aria role to toggleable commands
2 parents 9c5f31c + 09aec10 commit e9c5dce

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

packages/widgets/src/commandpalette.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,11 @@ namespace CommandPalette {
652652
*/
653653
readonly isToggled: boolean;
654654

655+
/**
656+
* Whether the command item is toggleable.
657+
*/
658+
readonly isToggleable: boolean;
659+
655660
/**
656661
* Whether the command item is visible.
657662
*/
@@ -779,8 +784,24 @@ namespace CommandPalette {
779784
renderItem(data: IItemRenderData): VirtualElement {
780785
let className = this.createItemClass(data);
781786
let dataset = this.createItemDataset(data);
787+
if (data.item.isToggleable) {
788+
return (
789+
h.li({
790+
className,
791+
dataset,
792+
role: 'checkbox',
793+
'aria-checked': `${data.item.isToggled}`
794+
},
795+
this.renderItemIcon(data),
796+
this.renderItemContent(data),
797+
this.renderItemShortcut(data))
798+
)
799+
}
782800
return (
783-
h.li({ className, dataset },
801+
h.li({
802+
className,
803+
dataset
804+
},
784805
this.renderItemIcon(data),
785806
this.renderItemContent(data),
786807
this.renderItemShortcut(data),
@@ -1551,6 +1572,13 @@ namespace Private {
15511572
return this._commands.isToggled(this.command, this.args);
15521573
}
15531574

1575+
/**
1576+
* Whether the command item is toggleable.
1577+
*/
1578+
get isToggleable(): boolean {
1579+
return this._commands.isToggleable(this.command, this.args);
1580+
}
1581+
15541582
/**
15551583
* Whether the command item is visible.
15561584
*/

0 commit comments

Comments
 (0)