Skip to content

Commit

Permalink
feat: add searchLabel to queryItemCascader, and defaultOpen prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jared-dickman committed Aug 29, 2024
1 parent 16f9d0d commit bb80cdc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/data-entry/QueryItem/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import { useMount } from 'src/hooks/useMount'
import { debounce } from 'src/utils/utils'

export interface ICascaderOption {
value: string | number
label?: React.ReactNode
value: string
label: ReactNode
searchLabel: string
children?: ICascaderOption[]
disabled?: boolean
}
Expand All @@ -32,6 +33,7 @@ export interface IQueryItemCascaderProps {
value?: Array<number | string>
disabled?: boolean
placement?: IBaseCascaderProps['placement']
defaultOpen?: IBaseCascaderProps['defaultOpen']
}

const Cascader = (props: IQueryItemCascaderProps) => {
Expand Down Expand Up @@ -99,6 +101,7 @@ const Cascader = (props: IQueryItemCascaderProps) => {
searchValue,
disabled: props.disabled,
value: selectedValue,
defaultOpen: props.defaultOpen,
placement: props.placement ?? 'bottomLeft',
onChange: (values: Array<number | string>, selectedOptions: any): void => {
setSelectedValue(values as string[])
Expand Down Expand Up @@ -132,7 +135,7 @@ const Cascader = (props: IQueryItemCascaderProps) => {
<>
{paths.map((path: ICascaderOption, index) => (
<>
{highlightMatches(path.label as string, inputValue.toLowerCase())}
{highlightMatches(path.searchLabel, inputValue.toLowerCase())}
{index < paths.length - 1 ? ' > ' : ''}
</>
))}
Expand Down

0 comments on commit bb80cdc

Please sign in to comment.