Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ describe('Table Controls component', () => {
});

spectator.triggerEventHandler(SearchBoxComponent, 'valueChange', 'testing');
spectator.tick(200);

expect(onChangeSpy).toHaveBeenCalledWith('testing');
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {
Output
} from '@angular/core';
import { IconType } from '@hypertrace/assets-library';
import { SubscriptionLifecycle, TypedSimpleChanges } from '@hypertrace/common';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { TypedSimpleChanges } from '@hypertrace/common';
import { IconSize } from '../../icon/icon-size';
import { MultiSelectJustify } from '../../multi-select/multi-select-justify';
import { MultiSelectSearchMode, TriggerLabelDisplayMode } from '../../multi-select/multi-select.component';
Expand All @@ -27,7 +25,6 @@ import {
@Component({
selector: 'ht-table-controls',
styleUrls: ['./table-controls.component.scss'],
providers: [SubscriptionLifecycle],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="table-controls" *ngIf="this.anyControlsEnabled">
Expand All @@ -38,6 +35,7 @@ import {
*ngIf="this.searchEnabled"
class="control search-box"
[placeholder]="this.searchPlaceholder || this.DEFAULT_SEARCH_PLACEHOLDER"
[debounceTime]="400"
(valueChange)="this.onSearchChange($event)"
></ht-search-box>

Expand Down Expand Up @@ -152,17 +150,8 @@ export class TableControlsComponent implements OnChanges {
return !!this.searchEnabled || this.viewToggleEnabled || this.selectControlsEnabled || this.checkboxControlsEnabled;
}

private readonly searchDebounceSubject: Subject<string> = new Subject<string>();

public constructor(
private readonly subscriptionLifecycle: SubscriptionLifecycle,
private readonly differFactory: IterableDiffers
) {
public constructor(private readonly differFactory: IterableDiffers) {
this.checkboxDiffer = this.differFactory.find([]).create();

this.subscriptionLifecycle.add(
this.searchDebounceSubject.pipe(debounceTime(200)).subscribe(text => this.searchChange.emit(text))
Copy link
Contributor

@anandtiwary anandtiwary Aug 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can really use the ootb debounceTime property of search box component. Additional subscription here is not required in this table.

Please update the time in search box component as well either ways

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah I forgot we added that - switched over to using that one (searchbox doesn't have a built in time, it's not debouncing by default)

);
}

public ngOnChanges(changes: TypedSimpleChanges<this>): void {
Expand Down Expand Up @@ -208,7 +197,7 @@ export class TableControlsComponent implements OnChanges {
}

public onSearchChange(text: string): void {
this.searchDebounceSubject.next(text);
this.searchChange.emit(text);
}

public onMultiSelectChange(select: TableSelectControl, selections: TableSelectControlOption[]): void {
Expand Down