Skip to content

search component added option inputValue, allows to set the value of input field without triggering a search #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion src/modules/search/components/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ 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,12 @@ export class SuiSearch<T> implements AfterViewInit, OnDestroy {
this._placeholder = placeholder;
}

// Sets the input value text without triggering a search.
@Input()
public set inputValue(query:string) {
this._inputValue = (query == '' || query == null)?false:query;
}

private _localeValues:ISearchLocaleValues;

public localeOverrides:RecursivePartial<ISearchLocaleValues>;
Expand All @@ -94,10 +101,16 @@ 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