-
Notifications
You must be signed in to change notification settings - Fork 143
fix : clearable select and add a story in storybook #546
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,10 +60,17 @@ export const FieldSelect = < | |
autoFocus={props.autoFocus} | ||
value={selectValue} | ||
isDisabled={props.isDisabled} | ||
// @ts-expect-error should fix the typing. This error pops when | ||
// we propagate the `selectProps` | ||
onChange={(option) => onChange(option?.value)} | ||
{...props.selectProps} | ||
onChange={(newValue, actionMeta) => { | ||
if (actionMeta.action === 'clear') { | ||
// Set the value to null on clear | ||
onChange(null); | ||
return; | ||
} | ||
// @ts-expect-error TODO should fix the typing. This error pops when | ||
// we propagate the `selectProps` | ||
onChange(newValue?.value); | ||
}} | ||
Comment on lines
+70
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification The typing issue can be fixed by properly typing the onChange handler The
Example locations that need attention:
🔗 Analysis chainConsider addressing the typing issue. The Let's check for similar typing patterns in other components: Let me gather more context about the Select components and their type definitions. Let me check the base Select component implementation to understand the typing issue better. Let me check the Chakra UI Select implementation since the code seems to be using Chakra's wrapped version of react-select. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for similar Select component usage patterns to understand the typing approach
ast-grep --pattern 'onChange={(newValue, actionMeta) => { $$$ }}'
# Look for other @ts-expect-error occurrences that might provide insights
rg "@ts-expect-error" -A 2
Length of output: 1100 Script: #!/bin/bash
# Check the type definitions and imports in both Select components
rg -A 10 "interface.*Props" src/components/Form/FieldSelect/
rg -A 10 "interface.*Props" src/components/Form/FieldMultiSelect/
# Look for Select component imports and their types
rg "import.*Select" src/components/Form/Field*
# Check the component definitions
ast-grep --pattern 'const FieldSelect: $_ = ($_) => { $$$ }'
ast-grep --pattern 'const FieldMultiSelect: $_ = ($_) => { $$$ }'
Length of output: 914 Script: #!/bin/bash
# Check the base Select component implementation and its types
rg -A 10 "interface.*Props" src/components/Select/
rg -A 10 "type.*Props" src/components/Select/
# Look for the Select component implementation
ast-grep --pattern 'const Select = ($_) => { $$$ }'
ast-grep --pattern 'export interface SelectProps { $$$ }'
# Check how the value and onChange props are typed
rg "onChange.*:" src/components/Select/
Length of output: 2048 Script: #!/bin/bash
# Check for Chakra Select component imports and types
rg "import.*chakra.*select" -i src/components/Select/
rg "ChakraReactSelect" -A 5 src/components/Select/
# Look for the value type definitions
rg "type.*Value" src/components/Select/
rg "interface.*Value" src/components/Select/
# Check for any type exports or re-exports
rg "export type" src/components/Select/
Length of output: 991 |
||
{...fieldProps} | ||
/> | ||
<FormFieldError /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want it to be nullish for most of the stories. For the change you made, please create a new schema