提交 d80f324e 编写于 作者: I isidor

action bar: introduce respectOrientationForPreviousAndNextKey and by default...

action bar: introduce respectOrientationForPreviousAndNextKey and by default respect both up/down and left/right for prev and next navigation

fixes #106439
上级 90a9985d
......@@ -35,6 +35,7 @@ export interface IActionBarOptions {
readonly triggerKeys?: ActionTrigger;
readonly allowContextMenu?: boolean;
readonly preventLoopNavigation?: boolean;
readonly respectOrientationForPreviousAndNextKey?: boolean;
}
export interface IActionOptions extends IActionViewItemOptions {
......@@ -104,27 +105,27 @@ export class ActionBar extends Disposable implements IActionRunner {
this.domNode.classList.add('animated');
}
let previousKey: KeyCode;
let nextKey: KeyCode;
let previousKeys: KeyCode[];
let nextKeys: KeyCode[];
switch (this._orientation) {
case ActionsOrientation.HORIZONTAL:
previousKey = KeyCode.LeftArrow;
nextKey = KeyCode.RightArrow;
previousKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.LeftArrow] : [KeyCode.LeftArrow, KeyCode.UpArrow];
nextKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.RightArrow] : [KeyCode.RightArrow, KeyCode.DownArrow];
break;
case ActionsOrientation.HORIZONTAL_REVERSE:
previousKey = KeyCode.RightArrow;
nextKey = KeyCode.LeftArrow;
previousKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.RightArrow] : [KeyCode.RightArrow, KeyCode.DownArrow];
nextKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.LeftArrow] : [KeyCode.LeftArrow, KeyCode.UpArrow];
this.domNode.className += ' reverse';
break;
case ActionsOrientation.VERTICAL:
previousKey = KeyCode.UpArrow;
nextKey = KeyCode.DownArrow;
previousKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.UpArrow] : [KeyCode.LeftArrow, KeyCode.UpArrow];
nextKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.DownArrow] : [KeyCode.RightArrow, KeyCode.DownArrow];
this.domNode.className += ' vertical';
break;
case ActionsOrientation.VERTICAL_REVERSE:
previousKey = KeyCode.DownArrow;
nextKey = KeyCode.UpArrow;
previousKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.DownArrow] : [KeyCode.RightArrow, KeyCode.DownArrow];
nextKeys = this.options.respectOrientationForPreviousAndNextKey ? [KeyCode.UpArrow] : [KeyCode.LeftArrow, KeyCode.UpArrow];
this.domNode.className += ' vertical reverse';
break;
}
......@@ -133,9 +134,9 @@ export class ActionBar extends Disposable implements IActionRunner {
const event = new StandardKeyboardEvent(e);
let eventHandled = true;
if (event.equals(previousKey)) {
if (previousKeys && (event.equals(previousKeys[0]) || event.equals(previousKeys[1]))) {
eventHandled = this.focusPrevious();
} else if (event.equals(nextKey)) {
} else if (nextKeys && (event.equals(nextKeys[0]) || event.equals(nextKeys[1]))) {
eventHandled = this.focusNext();
} else if (event.equals(KeyCode.Escape)) {
this._onDidCancel.fire();
......
......@@ -85,7 +85,8 @@ export class Menu extends ActionBar {
context: options.context,
actionRunner: options.actionRunner,
ariaLabel: options.ariaLabel,
triggerKeys: { keys: [KeyCode.Enter, ...(isMacintosh || isLinux ? [KeyCode.Space] : [])], keyDown: true }
triggerKeys: { keys: [KeyCode.Enter, ...(isMacintosh || isLinux ? [KeyCode.Space] : [])], keyDown: true },
respectOrientationForPreviousAndNextKey: true
});
this.menuElement = menuElement;
......
......@@ -649,10 +649,12 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
this.container.classList.add('checked');
this.container.setAttribute('aria-label', nls.localize('compositeActive', "{0} active", this.container.title));
this.container.setAttribute('aria-expanded', 'true');
this.container.setAttribute('aria-selected', 'true');
} else {
this.container.classList.remove('checked');
this.container.setAttribute('aria-label', this.container.title);
this.container.setAttribute('aria-expanded', 'false');
this.container.setAttribute('aria-selected', 'false');
}
this.updateStyles();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册