Skip to content

Commit

Permalink
update search due to edcarroll#343
Browse files Browse the repository at this point in the history
  • Loading branch information
restricted committed Jul 7, 2020
1 parent 09165eb commit 118e845
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/modules/search/components/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export interface IResultContext<T> extends ITemplateRefContext<T> {
export class SuiSearch<T> implements AfterViewInit, OnDestroy {
public dropdownService:DropdownService;
public searchService:SearchService<T, T>;

private _inputValue:any = false;

@ViewChild(SuiDropdownMenu)
private _menu:SuiDropdownMenu;

Expand Down Expand Up @@ -85,6 +86,11 @@ export class SuiSearch<T> implements AfterViewInit, OnDestroy {
this._placeholder = placeholder;
}

@Input()
public set inputValue(query:string) {
this._inputValue = (query == '' || query == null) ? false : query;
}

private _localeValues:ISearchLocaleValues;

public localeOverrides:RecursivePartial<ISearchLocaleValues>;
Expand All @@ -94,10 +100,15 @@ export class SuiSearch<T> implements AfterViewInit, OnDestroy {
}

public get query():string {
return this.searchService.query;
if(this._inputValue) {
return this._inputValue;
} else {
return this.searchService.query;
}
}

public set query(query:string) {
this._inputValue = false;
this.selectedResult = undefined;
// Initialise a delayed search.
this.searchService.updateQueryDelayed(query, () =>
Expand Down

0 comments on commit 118e845

Please sign in to comment.