mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 09:35:38 -05:00
Fix a bunch of strict issues (#11857)
* fix a bunch of strict issues * fix tests * fix tests
This commit is contained in:
@@ -26,9 +26,9 @@ const defaultOptions: IActionBarOptions = {
|
||||
export class OverflowActionBar extends ActionBar {
|
||||
// Elements
|
||||
private _overflow: HTMLElement;
|
||||
private _moreItemElement: HTMLElement;
|
||||
private _moreActionsElement: HTMLElement;
|
||||
private _previousWidth: number;
|
||||
private _moreItemElement?: HTMLElement;
|
||||
private _moreActionsElement?: HTMLElement;
|
||||
private _previousWidth: number = 0;
|
||||
|
||||
constructor(container: HTMLElement, options: IActionBarOptions = defaultOptions) {
|
||||
super(container, options);
|
||||
@@ -74,7 +74,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
this.createMoreItemElement();
|
||||
}
|
||||
|
||||
this._moreItemElement.style.display = 'block';
|
||||
this._moreItemElement!.style.display = 'block';
|
||||
while (width < fullWidth) {
|
||||
let index = this._actionsList.childNodes.length - 2; // remove the last toolbar action before the more actions '...'
|
||||
if (index > -1) {
|
||||
@@ -94,7 +94,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
this.collapseItem();
|
||||
break;
|
||||
} else if (!this._overflow.hasChildNodes()) {
|
||||
this._moreItemElement.style.display = 'none';
|
||||
this._moreItemElement!.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,23 +117,26 @@ export class OverflowActionBar extends ActionBar {
|
||||
|
||||
// change role to menuItem when it's in the overflow
|
||||
if ((<HTMLElement>this._overflow.firstChild).className !== 'taskbarSeparator') {
|
||||
(<HTMLElement>this._overflow.firstChild.firstChild).setAttribute('role', 'menuItem');
|
||||
(<HTMLElement>this._overflow.firstChild!.firstChild).setAttribute('role', 'menuItem');
|
||||
}
|
||||
}
|
||||
|
||||
public restoreItem(): void {
|
||||
let item = this._overflow.removeChild(this._overflow.firstChild);
|
||||
// change role back to button when it's in the toolbar
|
||||
if ((<HTMLElement>item).className !== 'taskbarSeparator') {
|
||||
(<HTMLElement>item.firstChild).setAttribute('role', 'button');
|
||||
}
|
||||
this._actionsList.insertBefore(item, this._actionsList.lastChild);
|
||||
let firstChild = this._overflow.firstChild;
|
||||
if (firstChild) {
|
||||
let item = this._overflow.removeChild(firstChild);
|
||||
// change role back to button when it's in the toolbar
|
||||
if ((<HTMLElement>item).className !== 'taskbarSeparator') {
|
||||
(<HTMLElement>item.firstChild).setAttribute('role', 'button');
|
||||
}
|
||||
this._actionsList.insertBefore(item, this._actionsList.lastChild);
|
||||
|
||||
// move placeholder in this._items if item isn't a separator
|
||||
if (!(<HTMLElement>item).classList.contains('taskbarSeparator')) {
|
||||
let placeHolderIndex = this._items.findIndex(i => i === undefined);
|
||||
let placeHolderItem = this._items.splice(placeHolderIndex, 1);
|
||||
this._items.splice(placeHolderIndex + 1, 0, placeHolderItem[0]);
|
||||
// move placeholder in this._items if item isn't a separator
|
||||
if (!(<HTMLElement>item).classList.contains('taskbarSeparator')) {
|
||||
let placeHolderIndex = this._items.findIndex(i => i === undefined);
|
||||
let placeHolderItem = this._items.splice(placeHolderIndex, 1);
|
||||
this._items.splice(placeHolderIndex + 1, 0, placeHolderItem[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +166,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
// Close overflow if Escape is pressed
|
||||
if (event.equals(KeyCode.Escape)) {
|
||||
this.hideOverflowDisplay();
|
||||
this._moreActionsElement.focus();
|
||||
this._moreActionsElement!.focus();
|
||||
} else if (event.equals(KeyCode.UpArrow)) {
|
||||
// up arrow on first element in overflow should move focus to the bottom of the overflow
|
||||
if (this._focusedItem === this._actionsList.childElementCount) {
|
||||
@@ -192,7 +195,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
|
||||
this._moreItemElement.appendChild(this._moreActionsElement);
|
||||
this._actionsList.appendChild(this._moreItemElement);
|
||||
this._items.push(undefined); // add place holder for more item element
|
||||
this._items.push(undefined!); // add place holder for more item element @anthonydresser, im not sure how this is working, vscode indexes into this value all the time...
|
||||
}
|
||||
|
||||
public moreElementOnClick(event: MouseEvent | StandardKeyboardEvent): void {
|
||||
@@ -324,7 +327,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
if (i === this._focusedItem) {
|
||||
// placeholder for location of moreActionsElement
|
||||
if (!actionItem) {
|
||||
this._moreActionsElement.focus();
|
||||
this._moreActionsElement!.focus();
|
||||
}
|
||||
else if (types.isFunction(actionItem.focus)) {
|
||||
actionItem.focus();
|
||||
@@ -362,7 +365,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
return this._overflow;
|
||||
}
|
||||
|
||||
public get focusedItem(): number {
|
||||
public get focusedItem(): number | undefined {
|
||||
return this._focusedItem;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user