-
Notifications
You must be signed in to change notification settings - Fork 32
Datagrid filter setFocus #542
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| /*! | ||
| * Copyright 2019 VMware, Inc. | ||
| * Copyright 2019-2023 VMware, Inc. | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| */ | ||
|
|
||
| import { Component, Host, OnDestroy } from '@angular/core'; | ||
| import { Component, ElementRef } from '@angular/core'; | ||
| import { AbstractControl, FormControl, FormGroup } from '@angular/forms'; | ||
| import { ClrDatagridFilter } from '@clr/angular'; | ||
| import { SelectOption } from '../../common/interfaces/select-option'; | ||
|
|
@@ -71,7 +71,7 @@ type BooleanFormGroup = FormGroup<{ [name: string]: AbstractControl<boolean, boo | |
| providers: [SubscriptionTracker], | ||
| }) | ||
| export class DatagridMultiSelectFilterComponent extends DatagridFilter<string[], DatagridMultiSelectFilterConfig> { | ||
| constructor(private filterContainer: ClrDatagridFilter, subTracker: SubscriptionTracker) { | ||
| constructor(filterContainer: ClrDatagridFilter, subTracker: SubscriptionTracker, private elemRef: ElementRef) { | ||
| super(filterContainer, subTracker); | ||
| } | ||
|
|
||
|
|
@@ -127,6 +127,10 @@ export class DatagridMultiSelectFilterComponent extends DatagridFilter<string[], | |
| !!Object.keys(this.formGroup.getRawValue()).filter((frmCtrl) => this.formGroup.get(frmCtrl).value).length | ||
| ); | ||
| } | ||
|
|
||
| protected setFocus() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a better approach is to have a method called
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the I agree that the very |
||
| this.elemRef?.nativeElement?.querySelector('input')?.focus(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| <form> | ||
| <input | ||
| #inputElement | ||
| type="text" | ||
| name="search" | ||
| class="clr-input" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're touching this file, we may as well remove the providers from here since it doesn't have any effect, the concrete classes need to add the providers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kepelrs discovered this while analyzing the SubscriptionTracker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC it was @irahov who discovered it first :)