Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/four-apples-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ensembleui/react-runtime": patch
---

Allow reset options on clear search in multiselect and search
15 changes: 5 additions & 10 deletions apps/kitchen-sink/src/ensemble/screens/home.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,12 @@ View:
placeholder: "Search or Select From Groups"
labelKey: name
valueKey: email
data: ${ensemble.storage.get('products')}
data: "${getProducts.body.users?.map((i) => ({ ...i, name: i.firstName + ' ' + i.lastName })) || []}"
onSearch:
executeCode: |
ensemble.invokeAPI('getProducts', { search: search }).then((res) => {
const users = res?.body?.users || [];
console.log(users , "users");
const newUsers = users.map((i) => ({ ...i, label: i.firstName + ' ' + i.lastName, name: i.firstName + ' ' + i.lastName, value: i.email }));
console.log(newUsers , "newUsers");
ensemble.storage.set('products', newUsers);
});
console.log("onSearch values: ", search);
invokeAPI:
name: getProducts
inputs:
search: ${search}
onChange:
executeCode: |
console.log("onChange values: ", search);
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/src/widgets/Form/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "@ensembleui/react-framework";
import { PlusCircleOutlined } from "@ant-design/icons";
import { Select as SelectComponent, Space, Form } from "antd";
import { get, isArray, isEmpty, isEqual, isObject, isString } from "lodash-es";
import { get, isArray, isEqual, isObject, isString } from "lodash-es";
import { useDebounce } from "react-use";
import { WidgetRegistry } from "../../registry";
import { useEnsembleAction } from "../../runtime/hooks/useEnsembleAction";
Expand Down Expand Up @@ -170,7 +170,7 @@ const MultiSelect: React.FC<MultiSelectProps> = (props) => {

useDebounce(
() => {
if (onSearchAction?.callback && !isEmpty(searchValue)) {
if (onSearchAction?.callback) {
onSearchAction.callback({ search: searchValue });
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/widgets/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const Search: React.FC<SearchProps> = ({

useDebounce(
() => {
if (onSearchAction?.callback && !isEmpty(searchValue)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sagardspeed2, didn't we add this for a reason previously? here: https://github.com/EnsembleUI/ensemble-react/pull/909/files#diff-c40bba994aece7636430625fad970ec08c0334f7edc12464e796ea3375086432R118

Could you please confirm that removing this won't cause any regressions?

if (onSearchAction?.callback) {
onSearchAction.callback({ search: searchValue });
}
},
Expand Down
Loading