Skip to content

Custom Tags for Multiselect #1801

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SelectInputInvalidConfig, useSelectInputValidate } from "./selectInputC

import { PaddingControl } from "../../controls/paddingControl";
import { MarginControl } from "../../controls/marginControl";
import { migrateOldData, withDefault } from "comps/generators/simpleGenerators";
import { migrateOldData } from "comps/generators/simpleGenerators";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";

let MultiSelectBasicComp = (function () {
Expand All @@ -35,6 +35,10 @@ let MultiSelectBasicComp = (function () {
validateState,
handleChange,
] = useSelectInputValidate(props);

const removeIllegalEntries = () => {
return props.value.value.filter?.((v) => valueSet.has(v))
}

return props.label({
required: props.required,
Expand All @@ -45,8 +49,8 @@ let MultiSelectBasicComp = (function () {
children: (
<SelectUIView
{...props}
mode={"multiple"}
value={props.value.value.filter?.((v) => valueSet.has(v))}
mode={props.allowCustomTags ? "tags" : "multiple"}
value={props.allowCustomTags ? props.value.value : removeIllegalEntries()}
onChange={handleChange}
dispatch={dispatch}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export const getStyle = (
padding: ${style.padding};
height: auto;
}
.ant-select-selection-search {
.ant-select-selection-search {
min-width: 50px;
padding: ${style.padding};
}
.ant-select-selection-search-input,
Expand Down Expand Up @@ -268,9 +269,10 @@ export const SelectUIView = (
placeholder={props.placeholder}
value={props.value}
showSearch={props.showSearch}
filterOption={(input, option) =>
option?.label.toLowerCase().includes(input.toLowerCase())
}
filterOption={(input, option) => {
if (!option) return false;
return String(option.label ?? option.value ?? "").toLowerCase().includes(input.toLowerCase());
}}
popupRender={(originNode: ReactNode) => (
<DropdownStyled $style={props.childrenInputFieldStyle as ChildrenMultiSelectStyleType}>
{originNode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { blurMethod, focusWithOptions } from "comps/utils/methodUtils";
export const SelectInputValidationChildren = {
required: BoolControl,
showValidationWhenEmpty: BoolControl,
allowCustomTags: BoolControl,
customRule: CustomRuleControl,
};
type ValidationComp = RecordConstructorToComp<typeof SelectInputValidationChildren>;
Expand Down Expand Up @@ -126,6 +127,9 @@ export const SelectInputValidationSection = (children: ValidationComp) => (
{children.showValidationWhenEmpty.propertyView({
label: trans("prop.showEmptyValidation"),
})}
{children.allowCustomTags.propertyView({
label: trans("prop.customTags")
})}
{children.customRule.propertyView({})}
</Section>
);
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export const en = {
"verticalGridCells": "Vertical Grid Cells",
"timeZone": "TimeZone",
"pickerMode": "Picker Mode",
"customTags": "Custom Tags"
},
"autoHeightProp": {
"auto": "Auto",
Expand Down
Loading