-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update useFilterSelect to allow retain filter and arguments…
… when field is changed
- Loading branch information
Showing
3 changed files
with
93 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
"@fn-sphere/filter": patch | ||
--- | ||
|
||
- Added the ability to retain the current filter and arguments when the field is changed in the `useFilterSelect` hook. | ||
- Introduced the `UpdateFieldOptions` type to specify the behavior when updating the field. | ||
- Updated the `FieldSelect` component to pass the `updateFieldOptions` to the `updateField` function. | ||
|
||
```tsx | ||
export type UpdateFieldOptions = { | ||
/** | ||
* Try to continue using the current filter when the field is changed. | ||
* | ||
* @default true | ||
*/ | ||
tryRetainFilter?: boolean; | ||
/** | ||
* Automatically select the first filter when the field is changed and the filter is not retained. | ||
* | ||
* @default true | ||
*/ | ||
autoSelectFirstFilter?: boolean; | ||
/** | ||
* Try to continue using the current args when the field is changed. | ||
* | ||
* @default true | ||
*/ | ||
tryRetainArgs?: boolean; | ||
}; | ||
|
||
<FieldSelect rule={rule} tryRetainFilter autoSelectFirstFilter tryRetainArgs />; | ||
``` |
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