Tables in Extensions need a way to override tab so that tabbing in table cells is not possible and tabbing takes control out of Table - this is the accessibility requirement for tables not having actionable cells. Keeping it as a switch so that we can continue having older behavior where needed.
This commit is contained in:
Udeesha Gautam
2019-08-22 11:42:09 -07:00
committed by GitHub
parent 5b94f8c4a7
commit 1a97313d19
4 changed files with 34 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ import { getContentHeight, getContentWidth, Dimension } from 'vs/base/browser/do
import { RowSelectionModel } from 'sql/base/browser/ui/table/plugins/rowSelectionModel.plugin';
import { CheckboxSelectColumn, ICheckboxCellActionEventArgs } from 'sql/base/browser/ui/table/plugins/checkboxSelectColumn.plugin';
import { Emitter, Event as vsEvent } from 'vs/base/common/event';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
@Component({
selector: 'modelview-table',
@@ -136,6 +138,20 @@ export default class TableComponent extends ComponentBase implements IComponent,
args: e
});
}));
this._table.grid.onKeyDown.subscribe((e: KeyboardEvent) => {
if (this.moveFocusOutWithTab) {
let event = new StandardKeyboardEvent(e);
if (event.equals(KeyMod.Shift | KeyCode.Tab)) {
e.stopImmediatePropagation();
(<HTMLElement>(<HTMLElement>this._inputContainer.nativeElement).previousElementSibling).focus();
} else if (event.equals(KeyCode.Tab)) {
e.stopImmediatePropagation();
(<HTMLElement>(<HTMLElement>this._inputContainer.nativeElement).nextElementSibling).focus();
}
}
});
}
}
@@ -313,4 +329,12 @@ export default class TableComponent extends ComponentBase implements IComponent,
public get ariaColumnCount(): number {
return this.getPropertyOrDefault<azdata.TableComponentProperties, number>((props) => props.ariaColumnCount, -1);
}
public set moveFocusOutWithTab(newValue: boolean) {
this.setPropertyFromUI<azdata.TableComponentProperties, boolean>((props, value) => props.moveFocusOutWithTab = value, newValue);
}
public get moveFocusOutWithTab(): boolean {
return this.getPropertyOrDefault<azdata.TableComponentProperties, boolean>((props) => props.moveFocusOutWithTab, false);
}
}