-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CPT-1478] Add enableResetSearch prop to Select and QB (#4075)
* [CPT-1478] Add enableResetSearch prop to Select and QB * [CPT-1478] Address review * Create seperate changesets for packages * Update multiselect input field type --------- Co-authored-by: Rasit Ozcan <[email protected]>
- Loading branch information
1 parent
6ef3992
commit 2d0c9d4
Showing
14 changed files
with
107 additions
and
3 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,5 @@ | ||
--- | ||
'@toptal/picasso': minor | ||
--- | ||
|
||
- add `enableResetSearch` prop to `Select` component to render reset icon which clears search input |
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,5 @@ | ||
--- | ||
'@toptal/picasso-query-builder': minor | ||
--- | ||
|
||
- add search input clearing functionality for `select` and `multiselect` filter types through filter configuration with `enableResetSearch` property. |
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
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
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
1 change: 1 addition & 0 deletions
1
packages/picasso/src/SelectBase/hooks/use-select-props/use-search-reset-handler/index.ts
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 @@ | ||
export { default } from './use-search-reset-handler' |
16 changes: 16 additions & 0 deletions
16
packages/picasso/src/SelectBase/hooks/use-select-props/use-search-reset-handler/test.ts
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,16 @@ | ||
import { renderHook } from '@testing-library/react' | ||
|
||
import { getUseSelectPropsMock } from '../mocks' | ||
import useSearchResetHandler from './use-search-reset-handler' | ||
|
||
describe('useSearchResetHandler', () => { | ||
it('handles reset', () => { | ||
const props = getUseSelectPropsMock() | ||
const { result } = renderHook(() => useSearchResetHandler(props)) | ||
|
||
result.current() | ||
|
||
expect(props.selectState.setFilterOptionsValue).toHaveBeenCalledTimes(1) | ||
expect(props.selectState.setFilterOptionsValue).toHaveBeenCalledWith('') | ||
}) | ||
}) |
10 changes: 10 additions & 0 deletions
10
...rc/SelectBase/hooks/use-select-props/use-search-reset-handler/use-search-reset-handler.ts
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,10 @@ | ||
import type { ValueType, UseSelectProps } from '../../../types' | ||
|
||
const useSearchResetHandler = | ||
<T extends ValueType, M extends boolean = false>({ | ||
selectState: { setFilterOptionsValue }, | ||
}: UseSelectProps<T, M>) => | ||
() => | ||
setFilterOptionsValue('') | ||
|
||
export default useSearchResetHandler |
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