-
Notifications
You must be signed in to change notification settings - Fork 138
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
fix(comp:cascader): searchValue not working after CascaderPanel added #1487
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ import { useControlledProp } from '@idux/cdk/utils' | |
|
||
export function usePanelProps( | ||
props: CascaderProps, | ||
searchValue: ComputedRef<string>, | ||
setOverlayOpened: (opened: boolean) => void, | ||
): ComputedRef<Partial<CascaderPanelProps>> { | ||
const [expandedKeys, setExpandedKeys] = useControlledProp(props, 'expandedKeys') | ||
|
@@ -43,6 +44,7 @@ export function usePanelProps( | |
|
||
searchable: props.searchable, | ||
searchFn: props.searchFn, | ||
searchValue: searchValue.value, | ||
strategy: props.strategy, | ||
virtual: props.virtual, | ||
|
||
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. the code review:
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,6 @@ export const cascaderPanelProps = { | |
onExpandedChange: [Function, Array] as PropType<MaybeArray<(expendedKeys: any[], data: CascaderData[]) => void>>, | ||
onLoaded: [Function, Array] as PropType<MaybeArray<(loadedKeys: any[], data: CascaderData) => void>>, | ||
onSelect: [Function, Array] as PropType<MaybeArray<(option: CascaderData, isSelected: boolean) => void>>, | ||
onSearch: [Function, Array] as PropType<MaybeArray<(value: string) => void>>, | ||
|
||
// private | ||
_virtualScrollHeight: { type: Number, default: 256 }, | ||
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. : This code appears to be a section of a codebase related to cascaderPanelProps. This code is responsible for setting up various callbacks including onExpandedChange, onLoaded, and onSelect. The 'onSearch' callback has been removed in this patch. From a code review perspective, it appears that the removal of the 'onSearch' callback was intentional and that no bugs have been introduced with this patch. However, depending on the desired behavior, some improvements could be made. For example, if the 'onSearch' callback is still necessary, then it would need to be re-introduced. Additionally, it is recommended to provide comments or documentation to explain why the 'onSearch' callback was removed. This will help future developers understand the codebase better. |
||
|
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.
the code review
First we will check if there are any typo errors or syntax errors in the code. We can't see any syntax errors, but it looks like the parameter "inputValue" is missing in the line below:
const panelProps = usePanelProps(props, setOverlayOpened)
We should add the missing parameter "inputValue" to the line:
const panelProps = usePanelProps(props, inputValue, setOverlayOpened)
Next, let's check if there are any potential bugs that could arise from this code. In the line below, we can see that the value of an event target is being retrieved and set as the inputValue.
const { value } = evt.target as HTMLInputElement
setInputValue(value)
It is possible that the event target is not a valid HTMLInputElement and thus the code may throw an error when trying to retrieve the value. To prevent this, we should add a check to make sure that the event target is indeed a HTMLInputElement before retrieving its value.