Skip to content

Commit

Permalink
chore(simple-combo): add explicit typing to methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofdiamond5 committed Mar 2, 2022
1 parent 557ffa4 commit 8b81359
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
/** @hidden @internal */
@HostListener('keydown.ArrowDown', ['$event'])
@HostListener('keydown.Alt.ArrowDown', ['$event'])
public onArrowDown(event: Event) {
public onArrowDown(event: Event): void {
if (this.collapsed) {
event.preventDefault();
event.stopPropagation();
Expand Down Expand Up @@ -174,15 +174,15 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public writeValue(value: any) {
public writeValue(value: any): void {
const oldSelection = this.selection;
this.selectionService.select_items(this.id, value ? [value] : [], true);
this.cdr.markForCheck();
this._value = this.createDisplayText(this.selection, oldSelection);
}

/** @hidden @internal */
public ngAfterViewInit() {
public ngAfterViewInit(): void {
this.virtDir.contentSizeChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
if (this.selection.length > 0) {
const index = this.virtDir.igxForOf.findIndex(e => {
Expand Down Expand Up @@ -225,7 +225,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public handleInputChange(event?: any) {
public handleInputChange(event?: any): void {
if (event !== undefined) {
this.filterValue = this._internalFilter = this.searchValue = typeof event === 'string' ? event : event.target.value;
}
Expand All @@ -247,7 +247,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public handleKeyDown(event: KeyboardEvent) {
public handleKeyDown(event: KeyboardEvent): void {
if (event.key === this.platformUtil.KEYMAP.ENTER) {
const filtered = this.filteredData.find(this.findMatch);
if (filtered === null || filtered === undefined) {
Expand Down Expand Up @@ -275,7 +275,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public handleKeyUp(event: KeyboardEvent) {
public handleKeyUp(event: KeyboardEvent): void {
if (event.key === this.platformUtil.KEYMAP.ARROW_DOWN) {
const firstItem = this.selectionService.first_item(this.id);
this.dropdown.focusedItem = firstItem && this.filteredData.length > 0
Expand All @@ -286,7 +286,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public handleItemKeyDown(event: KeyboardEvent) {
public handleItemKeyDown(event: KeyboardEvent): void {
if (event.key === this.platformUtil.KEYMAP.ARROW_UP && event.altKey) {
this.close();
this.comboInput.focus();
Expand All @@ -298,13 +298,13 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public handleItemClick() {
public handleItemClick(): void {
this.close();
this.comboInput.focus();
}

/** @hidden @internal */
public onBlur() {
public onBlur(): void {
if (this.collapsed) {
this.clearOnBlur();
}
Expand All @@ -317,7 +317,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public handleClear(event: Event) {
public handleClear(event: Event): void {
if (this.disabled) {
return;
}
Expand All @@ -337,14 +337,14 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public handleOpened() {
public handleOpened(): void {
this.triggerCheck();
this.dropdownContainer.nativeElement.focus();
this.opened.emit({ owner: this });
}

/** @hidden @internal */
public handleClosing(e: IBaseCancelableBrowserEventArgs) {
public handleClosing(e: IBaseCancelableBrowserEventArgs): void {
const args: IBaseCancelableBrowserEventArgs = { owner: this, event: e.event, cancel: e.cancel };
this.closing.emit(args);
e.cancel = args.cancel;
Expand All @@ -369,7 +369,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}

/** @hidden @internal */
public onClick(event: Event) {
public onClick(event: Event): void {
super.onClick(event);
if (this.comboInput.value.length === 0) {
this.virtDir.scrollTo(0);
Expand Down Expand Up @@ -411,7 +411,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
}
}

protected createDisplayText(newSelection: any[], oldSelection: any[]) {
protected createDisplayText(newSelection: any[], oldSelection: any[]): any {
if (this.isRemote) {
return this.getRemoteSelection(newSelection, oldSelection);
}
Expand All @@ -432,7 +432,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
this.setSelection(newSelection);
}

private clearOnBlur() {
private clearOnBlur(): void {
const filtered = this.filteredData.find(this.findMatch);
if (filtered === undefined || filtered === null || !this.selectedItem) {
this.clearAndClose();
Expand All @@ -455,7 +455,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
return this.displayKey ? element[this.displayKey] : element;
}

private clearAndClose() {
private clearAndClose(): void {
this.clearSelection(true);
this._internalFilter = '';
this.searchValue = '';
Expand Down

0 comments on commit 8b81359

Please sign in to comment.