mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 09:35:36 -05:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user