@sproutsocial/seeds-react-menu 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +8 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Autocomplete/AutocompleteTypes.ts +1 -0
- package/src/Autocomplete/MultiAutocomplete.tsx +2 -1
- package/src/Autocomplete/SingleAutocomplete.tsx +2 -1
- package/src/Autocomplete/__tests__/Autocomplete.test.tsx +18 -3
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ export type TypeBaseAutocompleteProps = TypeHigherOrderComponentProps &
|
|
|
16
16
|
/** Set multiSelect to true to allow multiple selections.
|
|
17
17
|
* Default: false*/
|
|
18
18
|
multiSelect?: boolean;
|
|
19
|
+
autoCloseOnEmpty?: boolean;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export type TypeSingleAutocompleteProps<
|
|
@@ -37,6 +37,7 @@ export const MultiAutocomplete = <
|
|
|
37
37
|
getA11yMultiStatusMessage,
|
|
38
38
|
onMultiSelectStateChange,
|
|
39
39
|
multiSelectStateReducer,
|
|
40
|
+
autoCloseOnEmpty = true,
|
|
40
41
|
...useComboboxProps
|
|
41
42
|
}: TypeMultiAutocompleteProps<I>) => {
|
|
42
43
|
/** Get a list of menuItems and children */
|
|
@@ -175,6 +176,7 @@ export const MultiAutocomplete = <
|
|
|
175
176
|
<MenuRootComponent
|
|
176
177
|
{...{
|
|
177
178
|
isListbox: true,
|
|
179
|
+
autoCloseOnEmpty,
|
|
178
180
|
items: allMenuItems,
|
|
179
181
|
itemToString,
|
|
180
182
|
initialSelectedItems,
|
|
@@ -192,7 +194,6 @@ export const MultiAutocomplete = <
|
|
|
192
194
|
focusOnContent: false,
|
|
193
195
|
...userPopoutProps,
|
|
194
196
|
}}
|
|
195
|
-
autoCloseOnEmpty
|
|
196
197
|
>
|
|
197
198
|
{children}
|
|
198
199
|
</MenuRootComponent>
|
|
@@ -20,6 +20,7 @@ export const SingleAutocomplete = <
|
|
|
20
20
|
MenuItemComponent,
|
|
21
21
|
itemToString = defaultItemToString,
|
|
22
22
|
getIsItemVisible,
|
|
23
|
+
autoCloseOnEmpty = true,
|
|
23
24
|
...useComboboxProps
|
|
24
25
|
}: TypeSingleAutocompleteProps<I>) => {
|
|
25
26
|
/** Get a list of menuItems and children */
|
|
@@ -63,6 +64,7 @@ export const SingleAutocomplete = <
|
|
|
63
64
|
<MenuRootComponent
|
|
64
65
|
{...{
|
|
65
66
|
isListbox: true,
|
|
67
|
+
autoCloseOnEmpty,
|
|
66
68
|
items: allMenuItems,
|
|
67
69
|
itemToString,
|
|
68
70
|
...useComboboxProps,
|
|
@@ -73,7 +75,6 @@ export const SingleAutocomplete = <
|
|
|
73
75
|
focusOnContent: false,
|
|
74
76
|
...userPopoutProps,
|
|
75
77
|
}}
|
|
76
|
-
autoCloseOnEmpty
|
|
77
78
|
>
|
|
78
79
|
{children}
|
|
79
80
|
</MenuRootComponent>
|
|
@@ -174,7 +174,7 @@ describe("Autocomplete Component", () => {
|
|
|
174
174
|
expect(customFilter).toHaveBeenCalled();
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
it("should close the dropdown when no items match the input", async () => {
|
|
177
|
+
it("should close the dropdown when no items match the input by default", async () => {
|
|
178
178
|
const { user } = render(<Autocomplete {...defaultAutocompleteProps} />);
|
|
179
179
|
const inputElement = screen.getByRole("combobox");
|
|
180
180
|
|
|
@@ -184,11 +184,26 @@ describe("Autocomplete Component", () => {
|
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
await waitFor(() => {
|
|
187
|
-
const
|
|
188
|
-
expect(
|
|
187
|
+
const emptyState = screen.queryByText("No items found");
|
|
188
|
+
expect(emptyState).not.toBeInTheDocument();
|
|
189
189
|
});
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
+
it("should not close the dropdown when no items match the input if supplied autoCloseOnEmpty={false}", async () => {
|
|
193
|
+
const { user } = render(
|
|
194
|
+
<Autocomplete {...defaultAutocompleteProps} autoCloseOnEmpty={false} />
|
|
195
|
+
);
|
|
196
|
+
const inputElement = screen.getByRole("combobox");
|
|
197
|
+
|
|
198
|
+
await act(async () => {
|
|
199
|
+
await user.click(inputElement);
|
|
200
|
+
await user.type(inputElement, "something not in the list");
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const emptyState = screen.getByText("No items found");
|
|
204
|
+
expect(emptyState).toBeInTheDocument();
|
|
205
|
+
});
|
|
206
|
+
|
|
192
207
|
it("should apply custom popoutProps.width to the popout container", async () => {
|
|
193
208
|
const { user } = render(
|
|
194
209
|
<Autocomplete
|