mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
support aria-expand for actions (#11869)
* support aria-expand for actions * update text
This commit is contained in:
@@ -218,8 +218,8 @@ export class AddFeatureTabAction extends Action {
|
|||||||
|
|
||||||
export class CollapseWidgetAction extends Action {
|
export class CollapseWidgetAction extends Action {
|
||||||
private static readonly ID = 'collapseWidget';
|
private static readonly ID = 'collapseWidget';
|
||||||
private static readonly COLLPASE_LABEL = nls.localize('collapseWidget', "Collapse");
|
private static readonly COLLPASE_LABEL = nls.localize('collapseWidget', "Collapse Widget");
|
||||||
private static readonly EXPAND_LABEL = nls.localize('expandWidget', "Expand");
|
private static readonly EXPAND_LABEL = nls.localize('expandWidget', "Expand Widget");
|
||||||
private static readonly COLLAPSE_ICON = 'codicon-chevron-up';
|
private static readonly COLLAPSE_ICON = 'codicon-chevron-up';
|
||||||
private static readonly EXPAND_ICON = 'codicon-chevron-down';
|
private static readonly EXPAND_ICON = 'codicon-chevron-down';
|
||||||
|
|
||||||
@@ -234,6 +234,7 @@ export class CollapseWidgetAction extends Action {
|
|||||||
collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL,
|
collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL,
|
||||||
collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON
|
collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON
|
||||||
);
|
);
|
||||||
|
this.expanded = !this.collpasedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
run(): Promise<boolean> {
|
run(): Promise<boolean> {
|
||||||
@@ -251,8 +252,9 @@ export class CollapseWidgetAction extends Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.collpasedState = collapsed;
|
this.collpasedState = collapsed;
|
||||||
this._setClass(this.collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON);
|
this.class = this.collpasedState ? CollapseWidgetAction.EXPAND_ICON : CollapseWidgetAction.COLLAPSE_ICON;
|
||||||
this.label = this.collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL;
|
this.label = this.collpasedState ? CollapseWidgetAction.EXPAND_LABEL : CollapseWidgetAction.COLLPASE_LABEL;
|
||||||
|
this.expanded = !this.collpasedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public set state(collapsed: boolean) {
|
public set state(collapsed: boolean) {
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ export class CollapseCellsAction extends ToggleableAction {
|
|||||||
shouldToggleTooltip: toggleTooltip,
|
shouldToggleTooltip: toggleTooltip,
|
||||||
isOn: false
|
isOn: false
|
||||||
});
|
});
|
||||||
|
this.expanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isCollapsed(): boolean {
|
public get isCollapsed(): boolean {
|
||||||
@@ -259,6 +260,7 @@ export class CollapseCellsAction extends ToggleableAction {
|
|||||||
}
|
}
|
||||||
private setCollapsed(value: boolean) {
|
private setCollapsed(value: boolean) {
|
||||||
this.toggle(value);
|
this.toggle(value);
|
||||||
|
this.expanded = !value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(context: URI): Promise<boolean> {
|
public async run(context: URI): Promise<boolean> {
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
|
|||||||
if (event.tooltip !== undefined) {
|
if (event.tooltip !== undefined) {
|
||||||
this.updateTooltip();
|
this.updateTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {{SQL CARBON EDIT}}
|
||||||
|
if (event.expanded !== undefined) {
|
||||||
|
this.updateExpanded();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get actionRunner(): IActionRunner {
|
get actionRunner(): IActionRunner {
|
||||||
@@ -197,6 +202,11 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
|
|||||||
// implement in subclass
|
// implement in subclass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {{SQL CARBON EDIT}}
|
||||||
|
protected updateExpanded(): void {
|
||||||
|
// implement in subclass
|
||||||
|
}
|
||||||
|
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
if (this.element) {
|
if (this.element) {
|
||||||
DOM.removeNode(this.element);
|
DOM.removeNode(this.element);
|
||||||
@@ -348,6 +358,17 @@ export class ActionViewItem extends BaseActionViewItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {{SQL CARBON EDIT}}
|
||||||
|
updateExpanded(): void {
|
||||||
|
if (this.label) {
|
||||||
|
if (this.getAction().expanded !== undefined) {
|
||||||
|
this.label.setAttribute('aria-expanded', `${this.getAction().expanded}`);
|
||||||
|
} else {
|
||||||
|
this.label.removeAttribute('aria-expanded');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SelectActionViewItem extends BaseActionViewItem {
|
export class SelectActionViewItem extends BaseActionViewItem {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface IAction extends IDisposable {
|
|||||||
class: string | undefined;
|
class: string | undefined;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
|
expanded: boolean | undefined; // {{SQL CARBON EDIT}}
|
||||||
run(event?: any): Promise<any>;
|
run(event?: any): Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ export interface IActionChangeEvent {
|
|||||||
readonly class?: string;
|
readonly class?: string;
|
||||||
readonly enabled?: boolean;
|
readonly enabled?: boolean;
|
||||||
readonly checked?: boolean;
|
readonly checked?: boolean;
|
||||||
|
readonly expanded?: boolean; // {{SQL CARBON EDIT}}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Action extends Disposable implements IAction {
|
export class Action extends Disposable implements IAction {
|
||||||
@@ -70,6 +72,7 @@ export class Action extends Disposable implements IAction {
|
|||||||
protected _cssClass: string | undefined;
|
protected _cssClass: string | undefined;
|
||||||
protected _enabled: boolean = true;
|
protected _enabled: boolean = true;
|
||||||
protected _checked: boolean = false;
|
protected _checked: boolean = false;
|
||||||
|
protected _expanded: boolean = false; // {{SQL CARBON EDIT}}
|
||||||
protected readonly _actionCallback?: (event?: any) => Promise<any>;
|
protected readonly _actionCallback?: (event?: any) => Promise<any>;
|
||||||
|
|
||||||
constructor(id: string, label: string = '', cssClass: string = '', enabled: boolean = true, actionCallback?: (event?: any) => Promise<any>) {
|
constructor(id: string, label: string = '', cssClass: string = '', enabled: boolean = true, actionCallback?: (event?: any) => Promise<any>) {
|
||||||
@@ -160,6 +163,22 @@ export class Action extends Disposable implements IAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {{SQL CARBON EDIT}}
|
||||||
|
get expanded(): boolean {
|
||||||
|
return this._expanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
set expanded(value: boolean) {
|
||||||
|
this._setExpanded(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected _setExpanded(value: boolean): void {
|
||||||
|
if (this._expanded !== value) {
|
||||||
|
this._expanded = value;
|
||||||
|
this._onDidChange.fire({ expanded: value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
run(event?: any, _data?: ITelemetryData): Promise<any> {
|
run(event?: any, _data?: ITelemetryData): Promise<any> {
|
||||||
if (this._actionCallback) {
|
if (this._actionCallback) {
|
||||||
return this._actionCallback(event);
|
return this._actionCallback(event);
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ class FiltersDropdownMenuActionViewItem extends DropdownMenuActionViewItem {
|
|||||||
checked: this.filters.showErrors,
|
checked: this.filters.showErrors,
|
||||||
class: undefined,
|
class: undefined,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
expanded: undefined, // {{SQL CARBON EDIT}}
|
||||||
id: 'showErrors',
|
id: 'showErrors',
|
||||||
label: Messages.MARKERS_PANEL_FILTER_LABEL_SHOW_ERRORS,
|
label: Messages.MARKERS_PANEL_FILTER_LABEL_SHOW_ERRORS,
|
||||||
run: async () => this.filters.showErrors = !this.filters.showErrors,
|
run: async () => this.filters.showErrors = !this.filters.showErrors,
|
||||||
@@ -209,6 +210,7 @@ class FiltersDropdownMenuActionViewItem extends DropdownMenuActionViewItem {
|
|||||||
checked: this.filters.showWarnings,
|
checked: this.filters.showWarnings,
|
||||||
class: undefined,
|
class: undefined,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
expanded: undefined, // {{SQL CARBON EDIT}}
|
||||||
id: 'showWarnings',
|
id: 'showWarnings',
|
||||||
label: Messages.MARKERS_PANEL_FILTER_LABEL_SHOW_WARNINGS,
|
label: Messages.MARKERS_PANEL_FILTER_LABEL_SHOW_WARNINGS,
|
||||||
run: async () => this.filters.showWarnings = !this.filters.showWarnings,
|
run: async () => this.filters.showWarnings = !this.filters.showWarnings,
|
||||||
@@ -219,6 +221,7 @@ class FiltersDropdownMenuActionViewItem extends DropdownMenuActionViewItem {
|
|||||||
checked: this.filters.showInfos,
|
checked: this.filters.showInfos,
|
||||||
class: undefined,
|
class: undefined,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
expanded: undefined, // {{SQL CARBON EDIT}}
|
||||||
id: 'showInfos',
|
id: 'showInfos',
|
||||||
label: Messages.MARKERS_PANEL_FILTER_LABEL_SHOW_INFOS,
|
label: Messages.MARKERS_PANEL_FILTER_LABEL_SHOW_INFOS,
|
||||||
run: async () => this.filters.showInfos = !this.filters.showInfos,
|
run: async () => this.filters.showInfos = !this.filters.showInfos,
|
||||||
@@ -231,6 +234,7 @@ class FiltersDropdownMenuActionViewItem extends DropdownMenuActionViewItem {
|
|||||||
class: undefined,
|
class: undefined,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
id: 'activeFile',
|
id: 'activeFile',
|
||||||
|
expanded: undefined, // {{SQL CARBON EDIT}}
|
||||||
label: Messages.MARKERS_PANEL_FILTER_LABEL_ACTIVE_FILE,
|
label: Messages.MARKERS_PANEL_FILTER_LABEL_ACTIVE_FILE,
|
||||||
run: async () => this.filters.activeFile = !this.filters.activeFile,
|
run: async () => this.filters.activeFile = !this.filters.activeFile,
|
||||||
tooltip: '',
|
tooltip: '',
|
||||||
@@ -240,6 +244,7 @@ class FiltersDropdownMenuActionViewItem extends DropdownMenuActionViewItem {
|
|||||||
checked: this.filters.excludedFiles,
|
checked: this.filters.excludedFiles,
|
||||||
class: undefined,
|
class: undefined,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
expanded: undefined, // {{SQL CARBON EDIT}}
|
||||||
id: 'useFilesExclude',
|
id: 'useFilesExclude',
|
||||||
label: Messages.MARKERS_PANEL_FILTER_LABEL_EXCLUDED_FILES,
|
label: Messages.MARKERS_PANEL_FILTER_LABEL_EXCLUDED_FILES,
|
||||||
run: async () => this.filters.excludedFiles = !this.filters.excludedFiles,
|
run: async () => this.filters.excludedFiles = !this.filters.excludedFiles,
|
||||||
|
|||||||
Reference in New Issue
Block a user