Skip to content

Commit

Permalink
fix: allow any component as a Label, include placement prop in base c…
Browse files Browse the repository at this point in the history
…ascader
  • Loading branch information
jared-dickman committed Aug 26, 2024
1 parent 2cd11a8 commit 16f9d0d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 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,8 @@ import { useMount } from 'src/hooks/useMount'
import { debounce } from 'src/utils/utils'

export interface ICascaderOption {
value: string
label: string
value: string | number
label?: React.ReactNode
children?: ICascaderOption[]
disabled?: boolean
}
Expand All @@ -31,6 +31,7 @@ export interface IQueryItemCascaderProps {
loadData?: (value: string) => Promise<void>
value?: Array<number | string>
disabled?: boolean
placement?: IBaseCascaderProps['placement']
}

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

0 comments on commit 16f9d0d

Please sign in to comment.