Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramakrishnan24689 committed Jul 10, 2023
1 parent b54ebe8 commit cf93a6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions SearchBox/SearchBox/components/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export const SearchBoxComponent = React.memo((props: ISearchBoxComponentProps) =
}, [value]);

function onChangeEvent(ev?: React.ChangeEvent<HTMLInputElement>, newValue?: string) {
setSearchText(newValue);
onChange(ev, newValue);
// pass empty string in case the value is undefined or null
setSearchText(newValue ?? '');
onChange(ev, newValue ?? '');
}

const searchboxStyles = React.useMemo(() => {
Expand Down
4 changes: 2 additions & 2 deletions SearchBox/SearchBox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ export class SearchBox implements ComponentFramework.ReactControl<IInputs, IOutp
* Called when a change is detected from the control. Updates the searchTextValue variable that is assigned to the output SearchText.
* @param newValue a string returned as the input search text
*/
private onChanged = (event?: React.ChangeEvent<HTMLInputElement>, newValue?: string): void => {
private onChanged = (event: React.ChangeEvent<HTMLInputElement>, newValue: string): void => {
// If the new Value is different from searchTextValue
if (this.searchTextValue !== newValue) {
this.searchTextValue = newValue ?? '';
this.searchTextValue = newValue;
this.delayOutput
? this.debouncedOutputChanged && this.debouncedOutputChanged()
: this.notifyOutputChanged && this.notifyOutputChanged();
Expand Down

0 comments on commit cf93a6b

Please sign in to comment.