Skip to content

Commit 013ae91

Browse files
authored
expose notFoundContent property for MultiSelect widget (#1046)
1 parent 85108e0 commit 013ae91

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.changeset/shaggy-lamps-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ensembleui/react-runtime": patch
3+
---
4+
5+
expose notFoundContent property for MultiSelect widget

packages/runtime/src/widgets/Form/MultiSelect.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export type MultiSelectProps = {
7373
maxTagCount: Expression<number | "responsive">;
7474
/** Max tag text length to show */
7575
maxTagTextLength: Expression<number>;
76+
notFoundContent?: Expression<string> | { [key: string]: unknown };
7677
} & EnsembleWidgetProps<MultiSelectStyles> &
7778
FormInputProps<object[] | string[]>;
7879

@@ -269,6 +270,18 @@ const MultiSelect: React.FC<MultiSelectProps> = (props) => {
269270
<Dropdown menu={menu} newOption={newOption} />
270271
);
271272

273+
const notFoundContentRenderer = useMemo(() => {
274+
const notFoundContent = values?.notFoundContent;
275+
276+
if (!notFoundContent) {
277+
return "No Results";
278+
}
279+
280+
return isString(notFoundContent)
281+
? notFoundContent
282+
: EnsembleRuntime.render([unwrapWidget(notFoundContent)]);
283+
}, [values?.notFoundContent]);
284+
272285
return (
273286
<>
274287
<style>{`
@@ -357,7 +370,7 @@ const MultiSelect: React.FC<MultiSelectProps> = (props) => {
357370
: undefined
358371
}
359372
mode={values?.allowCreateOptions ? "tags" : "multiple"}
360-
notFoundContent="No Results"
373+
notFoundContent={notFoundContentRenderer}
361374
onChange={handleChange}
362375
onSearch={handleSearch} // required for display new custom option with Dropdown element
363376
optionFilterProp="children"

0 commit comments

Comments
 (0)