-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add onSelect prop to FilterSearch (#323)
Add an `onSelect` prop to `FilterSearch` and deprecate `searchOnSelect`. If an `onSelect` function is passed in, the default selecting (and searching) logic is bypassed and we call the `onSelect`. If `searchOnSelect=true` is passed with an `onSelect`, we log a console warning that the former will be ignored. To allow for the UCSD use case mentioned in the spec, `currentFilter` was updated to allow any `StaticFilter`, not just a field value filter. J=SLAP-2431 TEST=auto, manual See that the added Jest tests pass. In the test-site, pass in an `onSelect` function that matches the current functionality with `searchOnSelect` as either true or false. Also, mimic a UCSD-like use case with compound filters and see that the component behaves correctly when selecting and un-selecting a filter. If both an `onSelect` and `searchOnSelect=true` are passed, see that a console warning is logged.
- Loading branch information
Showing
16 changed files
with
264 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-ui-react](./search-ui-react.md) > [FilterSearchProps](./search-ui-react.filtersearchprops.md) > [onSelect](./search-ui-react.filtersearchprops.onselect.md) | ||
|
||
## FilterSearchProps.onSelect property | ||
|
||
A function which is called when a filter is selected. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
onSelect?: (params: OnSelectParams) => void; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-ui-react](./search-ui-react.md) > [OnSelectParams](./search-ui-react.onselectparams.md) > [currentFilter](./search-ui-react.onselectparams.currentfilter.md) | ||
|
||
## OnSelectParams.currentFilter property | ||
|
||
The previously selected filter. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
currentFilter: StaticFilter | undefined; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/search-ui-react.onselectparams.executefiltersearch.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-ui-react](./search-ui-react.md) > [OnSelectParams](./search-ui-react.onselectparams.md) > [executeFilterSearch](./search-ui-react.onselectparams.executefiltersearch.md) | ||
|
||
## OnSelectParams.executeFilterSearch property | ||
|
||
A function that executes a filter search and updates the input and dropdown options with the response. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
executeFilterSearch: (query?: string) => Promise<FilterSearchResponse | undefined>; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-ui-react](./search-ui-react.md) > [OnSelectParams](./search-ui-react.onselectparams.md) | ||
|
||
## OnSelectParams interface | ||
|
||
The parameters that are passed into [FilterSearchProps.onSelect](./search-ui-react.filtersearchprops.onselect.md)<!-- -->. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface OnSelectParams | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [currentFilter](./search-ui-react.onselectparams.currentfilter.md) | StaticFilter \| undefined | The previously selected filter. | | ||
| [executeFilterSearch](./search-ui-react.onselectparams.executefiltersearch.md) | (query?: string) => Promise<FilterSearchResponse \| undefined> | A function that executes a filter search and updates the input and dropdown options with the response. | | ||
| [newDisplayName](./search-ui-react.onselectparams.newdisplayname.md) | string | The display name of the newly selected filter. | | ||
| [newFilter](./search-ui-react.onselectparams.newfilter.md) | FieldValueStaticFilter | The newly selected filter. | | ||
| [setCurrentFilter](./search-ui-react.onselectparams.setcurrentfilter.md) | (filter: StaticFilter) => void | A function that sets which filter the component is currently associated with. | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-ui-react](./search-ui-react.md) > [OnSelectParams](./search-ui-react.onselectparams.md) > [newDisplayName](./search-ui-react.onselectparams.newdisplayname.md) | ||
|
||
## OnSelectParams.newDisplayName property | ||
|
||
The display name of the newly selected filter. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
newDisplayName: string; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-ui-react](./search-ui-react.md) > [OnSelectParams](./search-ui-react.onselectparams.md) > [newFilter](./search-ui-react.onselectparams.newfilter.md) | ||
|
||
## OnSelectParams.newFilter property | ||
|
||
The newly selected filter. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
newFilter: FieldValueStaticFilter; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/search-ui-react](./search-ui-react.md) > [OnSelectParams](./search-ui-react.onselectparams.md) > [setCurrentFilter](./search-ui-react.onselectparams.setcurrentfilter.md) | ||
|
||
## OnSelectParams.setCurrentFilter property | ||
|
||
A function that sets which filter the component is currently associated with. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
setCurrentFilter: (filter: StaticFilter) => void; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.