Skip to content

Commit e96c985

Browse files
authored
Merge pull request #3529 from czwe-01/thulasizwe/en/dropdown-tag
fix: search for values data source
2 parents b9fb07c + 37bd62e commit e96c985

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

shesha-reactjs/src/components/dropdown/dropdown.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ export const Dropdown: FC<IDropdownProps> = ({
107107
};
108108
}, [labelCustomJs, outcomeValueFunc, incomeValueFunc]);
109109

110+
const filterOption = (input, option) => {
111+
if (typeof option?.children === 'string' && typeof input === 'string') {
112+
return option?.children?.toLowerCase().indexOf(input?.toLowerCase()) >= 0;
113+
}
114+
return false;
115+
};
116+
110117
if (dataSourceType === 'referenceList') {
111118
return (
112119
<GenericRefListDropDown<any>
@@ -131,6 +138,7 @@ export const Dropdown: FC<IDropdownProps> = ({
131138
getLabeledValue={getLabeledValue}
132139
getOptionFromFetchedItem={getOptionFromFetchedItem}
133140
displayStyle={displayStyle}
141+
filterOption={filterOption}
134142
incomeValueFunc={incomeValueFunc}
135143
outcomeValueFunc={outcomeValueFunc}
136144
/>
@@ -146,6 +154,8 @@ export const Dropdown: FC<IDropdownProps> = ({
146154
return options?.filter(({ value: currentValue }) => selectedValues.indexOf(currentValue) > -1)?.map(({ label }) => ({ label }));
147155
};
148156

157+
158+
149159
if (readOnly) {
150160
return <ReadOnlyDisplayFormItem
151161
showIcon={showIcon}
@@ -181,6 +191,8 @@ export const Dropdown: FC<IDropdownProps> = ({
181191
popupMatchSelectWidth={false}
182192
style={{ width: 'max-content', height: 'max-content' }}
183193
placeholder={placeholder}
194+
showSearch
195+
filterOption={filterOption}
184196
labelRender={(props) => {
185197
const option = options.find((o) => o.value === props.value);
186198
return <ReflistTag
@@ -210,6 +222,7 @@ export const Dropdown: FC<IDropdownProps> = ({
210222
{...commonSelectProps}
211223
style={{ ...style }}
212224
showSearch
225+
filterOption={filterOption}
213226
placeholder={placeholder}
214227
{...(displayStyle === 'tags' ? {
215228
labelRender: (props) => {
@@ -230,7 +243,7 @@ export const Dropdown: FC<IDropdownProps> = ({
230243
}
231244
>
232245
{options?.map(({ value: localValue, label }) => (
233-
<Select.Option value={localValue} key={localValue}>
246+
<Select.Option value={localValue} key={label}>
234247
{label}
235248
</Select.Option>
236249
))}

shesha-reactjs/src/components/refListDropDown/genericRefListDropDown.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const GenericRefListDropDown = <TValue,>(props: IGenericRefListDropDownPr
2727
getOptionFromFetchedItem,
2828
incomeValueFunc,
2929
outcomeValueFunc,
30+
filterOption,
3031
displayStyle,
3132
tagStyle,
3233
showIcon,
@@ -148,12 +149,7 @@ export const GenericRefListDropDown = <TValue,>(props: IGenericRefListDropDownPr
148149
allowClear,
149150
loading: refListLoading,
150151
disabled,
151-
filterOption: (input, option) => {
152-
if (typeof option?.children === 'string' && typeof input === 'string') {
153-
return option?.children?.toLowerCase().indexOf(input?.toLowerCase()) >= 0;
154-
}
155-
return false;
156-
},
152+
filterOption: filterOption,
157153
...rest,
158154
onChange: handleChange,
159155
value: wrapValue(value, options),

shesha-reactjs/src/designer-components/dropdown/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const DropdownComponent: IToolboxComponent<IDropdownComponentProps, ITextFieldCo
6363
defaultValue={calculatedModel.defaultValue}
6464
value={value}
6565
size={model?.size}
66-
tagStyle={{ ...tagStyle, justifyContent: tagStyle?.textAlign }}
66+
tagStyle={{ ...tagStyle, alignContent: 'center' }}
6767
onChange={onChangeInternal}
6868
/>;
6969
}}

shesha-reactjs/src/designer-components/dropdown/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export const defaultTagStyles = (): IStyleType => {
3939
weight: '400',
4040
size: 14,
4141
color: '#000',
42-
type: 'Segoe UI'
42+
type: 'Segoe UI',
43+
align: 'center'
4344
},
4445
border: {
4546
border: {

shesha-reactjs/src/designer-components/numberField/numberField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const NumberFieldComponent: IToolboxComponent<INumberFieldComponentProps, INumbe
7878
{(value, onChange) => {
7979
const customEvents = calculatedModel.eventHandlers;
8080
const onChangeInternal = (val: React.ChangeEvent<HTMLInputElement>) => {
81-
const newValue = !val ? undefined : model.highPrecision ? val : parseInt(val + '', 10);
81+
const newValue = val === undefined ? undefined : model.highPrecision ? val : parseInt(val + '', 10);
8282
customEvents.onChange(newValue);
8383
onChange(newValue);
8484
};

0 commit comments

Comments
 (0)