diff --git a/src/components/data-entry/QueryItem/Cascader.tsx b/src/components/data-entry/QueryItem/Cascader.tsx index 36c340185..fc600c478 100644 --- a/src/components/data-entry/QueryItem/Cascader.tsx +++ b/src/components/data-entry/QueryItem/Cascader.tsx @@ -117,23 +117,18 @@ export const Cascader = (props: ICascaderProps) => { if (isOpen) inputClasses += ' query-item--open' if (selectedValue && selectedValue.length != 0) inputClasses += ' query-item--selected' if (props.errorMessage) inputClasses += ' query-item--error' + const displayValue = selectedDisplayValue ?? selectedValue.slice(-1) return ( <> - ) : ( - - ) - } + value={displayValue} + prefix={getIcon()} /> {props.errorMessage && {props.errorMessage}} @@ -142,13 +137,21 @@ export const Cascader = (props: ICascaderProps) => { function highlightMatches(source: string, valueToHighlight: string): ReactNode { const lowerSource = source.toLowerCase() - return lowerSource.indexOf(valueToHighlight) === -1 ? (<>{ source }) : ( + return lowerSource.indexOf(valueToHighlight) === -1 ? ( + <>{source} + ) : ( <> {source.slice(0, lowerSource.indexOf(valueToHighlight))} - {source.slice(lowerSource.indexOf(valueToHighlight), lowerSource.indexOf(valueToHighlight) + valueToHighlight.length)} + {source.slice( + lowerSource.indexOf(valueToHighlight), + lowerSource.indexOf(valueToHighlight) + valueToHighlight.length, + )} - {highlightMatches(source.slice(lowerSource.indexOf(valueToHighlight) + valueToHighlight.length), valueToHighlight)} + {highlightMatches( + source.slice(lowerSource.indexOf(valueToHighlight) + valueToHighlight.length), + valueToHighlight, + )} ) } @@ -169,4 +172,12 @@ export const Cascader = (props: ICascaderProps) => { }) return result } + + function getIcon() { + return props.icon ? ( + + ) : ( + + ) + } }