@availity/mui-autocomplete 2.2.5 → 2.2.7
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/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/introduction.mdx +1 -1
- package/package.json +7 -7
- package/src/lib/AsyncAutocomplete.stories.tsx +1 -1
- package/src/lib/AsyncAutocomplete.test.tsx +80 -57
- package/src/lib/AsyncAutocomplete.tsx +2 -2
- package/src/lib/Autocomplete.stories.tsx +3 -3
- package/src/lib/CodesAutocomplete.stories.tsx +1 -1
- package/src/lib/OrganizationAutocomplete.stories.tsx +1 -1
- package/src/lib/ProviderAutocomplete.stories.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [2.2.7](https://github.com/Availity/element/compare/@availity/mui-autocomplete@2.2.6...@availity/mui-autocomplete@2.2.7) (2026-05-27)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-form-utils` updated to version `2.2.6`
|
|
10
|
+
* `mui-textfield` updated to version `2.2.6`
|
|
11
|
+
## [2.2.6](https://github.com/Availity/element/compare/@availity/mui-autocomplete@2.2.5...@availity/mui-autocomplete@2.2.6) (2026-03-16)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **mui-autocomplete:** expand scroll check area for asyncautocomplete ([4cc7229](https://github.com/Availity/element/commit/4cc7229871f77afce0a21e5cd8741f3c92c2b721))
|
|
17
|
+
|
|
5
18
|
## [2.2.5](https://github.com/Availity/element/compare/@availity/mui-autocomplete@2.2.4...@availity/mui-autocomplete@2.2.5) (2026-03-03)
|
|
6
19
|
|
|
7
20
|
### Dependency Updates
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
This package extends the MUI Autocomplete component: [MUI Autocomplete Docs](https://mui.com/components/autocomplete/)
|
|
12
12
|
|
|
13
|
-
Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/form-components-autocomplete-
|
|
13
|
+
Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/form-components-uncontrolled-fields-autocomplete-readme--docs)
|
|
14
14
|
|
|
15
15
|
Availity standards for design and usage can be found in the [Availity Design Guide](https://design.availity.com/2e36e50c7)
|
|
16
16
|
|
package/dist/index.js
CHANGED
|
@@ -227,7 +227,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
227
227
|
const handleAddingOptions = (event) => __async(null, null, function* () {
|
|
228
228
|
const listboxNode = event.currentTarget;
|
|
229
229
|
const difference = listboxNode.scrollHeight - (listboxNode.scrollTop + listboxNode.clientHeight);
|
|
230
|
-
if (difference <=
|
|
230
|
+
if (difference <= 10 && !isLoading && !isFetching && hasNextPage) {
|
|
231
231
|
fetchNextPage();
|
|
232
232
|
}
|
|
233
233
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -185,7 +185,7 @@ var AsyncAutocomplete = (_a) => {
|
|
|
185
185
|
const handleAddingOptions = (event) => __async(null, null, function* () {
|
|
186
186
|
const listboxNode = event.currentTarget;
|
|
187
187
|
const difference = listboxNode.scrollHeight - (listboxNode.scrollTop + listboxNode.clientHeight);
|
|
188
|
-
if (difference <=
|
|
188
|
+
if (difference <= 10 && !isLoading && !isFetching && hasNextPage) {
|
|
189
189
|
fetchNextPage();
|
|
190
190
|
}
|
|
191
191
|
});
|
package/introduction.mdx
CHANGED
|
@@ -2,7 +2,7 @@ import { Markdown, Meta } from '@storybook/addon-docs/blocks';
|
|
|
2
2
|
import ReadMe from './README.md?raw';
|
|
3
3
|
import CHANGELOG from './CHANGELOG.md?raw';
|
|
4
4
|
|
|
5
|
-
<Meta title="Form Components/Autocomplete/
|
|
5
|
+
<Meta title="Form Components/Uncontrolled Fields/Autocomplete/README" />
|
|
6
6
|
|
|
7
7
|
<Markdown>{ReadMe}</Markdown>
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-autocomplete",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"description": "Availity MUI Autocomplete Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"availity",
|
|
9
9
|
"mui"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://availity.github.io/element/?path=/docs/form-components-autocomplete-
|
|
11
|
+
"homepage": "https://availity.github.io/element/?path=/docs/form-components-uncontrolled-fields-autocomplete-readme--docs",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/Availity/element/issues"
|
|
14
14
|
},
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"qs": "^6.15.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@availity/api-axios": "^12.
|
|
49
|
-
"@availity/mui-form-utils": "^2.0.
|
|
48
|
+
"@availity/api-axios": "^12.2.1",
|
|
49
|
+
"@availity/mui-form-utils": "^2.0.6",
|
|
50
50
|
"@availity/mui-icon": "^2.1.0",
|
|
51
|
-
"@availity/mui-textfield": "^2.0.
|
|
51
|
+
"@availity/mui-textfield": "^2.0.6",
|
|
52
52
|
"@mui/material": "^7.3.4",
|
|
53
53
|
"@tanstack/react-query": "^4.36.1",
|
|
54
54
|
"react": "19.2.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@availity/api-axios": "^12.0.0",
|
|
61
|
-
"@availity/mui-form-utils": "^2.0.
|
|
62
|
-
"@availity/mui-textfield": "^2.0.
|
|
61
|
+
"@availity/mui-form-utils": "^2.0.6",
|
|
62
|
+
"@availity/mui-textfield": "^2.0.6",
|
|
63
63
|
"@mui/material": "^7.0.0",
|
|
64
64
|
"@tanstack/react-query": "^4.36.1",
|
|
65
65
|
"react": ">=17.0.0"
|
|
@@ -6,7 +6,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
6
6
|
import { AsyncAutocomplete } from './AsyncAutocomplete';
|
|
7
7
|
|
|
8
8
|
const meta: Meta<typeof AsyncAutocomplete> = {
|
|
9
|
-
title: 'Form Components/
|
|
9
|
+
title: 'Form Components/Uncontrolled Fields/AsyncAutocomplete',
|
|
10
10
|
component: AsyncAutocomplete,
|
|
11
11
|
tags: ['autodocs'],
|
|
12
12
|
args: {
|
|
@@ -5,6 +5,7 @@ import { server } from '@availity/mock/src/lib/server';
|
|
|
5
5
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
6
6
|
|
|
7
7
|
import { AsyncAutocomplete } from './AsyncAutocomplete';
|
|
8
|
+
import { mock } from 'node:test';
|
|
8
9
|
|
|
9
10
|
const api = new AvApi({ name: 'example' } as ApiConfig);
|
|
10
11
|
|
|
@@ -182,63 +183,85 @@ describe('AsyncAutocomplete', () => {
|
|
|
182
183
|
});
|
|
183
184
|
});
|
|
184
185
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
186
|
+
test('should call loadOptions when scroll to the bottom', async () => {
|
|
187
|
+
const mockLoadOptions = jest.fn(loadOptions);
|
|
188
|
+
const client = new QueryClient();
|
|
189
|
+
|
|
190
|
+
render(
|
|
191
|
+
<QueryClientProvider client={client}>
|
|
192
|
+
<AsyncAutocomplete queryKey="test-loadoptions-scroll" loadOptions={mockLoadOptions} limit={10} FieldProps={{ label: 'Test' }} />
|
|
193
|
+
</QueryClientProvider>
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const input = screen.getByRole('combobox');
|
|
197
|
+
fireEvent.click(input);
|
|
198
|
+
fireEvent.keyDown(input, { key: 'ArrowUp' });
|
|
199
|
+
|
|
200
|
+
const listbox = await screen.findByRole('listbox');
|
|
201
|
+
Object.defineProperty(listbox, 'scrollHeight', { value: 500, writable: true });
|
|
202
|
+
Object.defineProperty(listbox, 'clientHeight', { value: 100, writable: true });
|
|
203
|
+
Object.defineProperty(listbox, 'scrollTop', { value: 0, writable: true });
|
|
204
|
+
|
|
205
|
+
// wait for no-scroll loading fallback to finish before testing scroll behavior
|
|
206
|
+
await waitFor(() => expect(() => screen.getByAltText('Loading')).toThrow());
|
|
207
|
+
const initialCallCount = mockLoadOptions.mock.calls.length;
|
|
208
|
+
|
|
209
|
+
fireEvent.scroll(listbox, { target: { scrollTop: 200 } });
|
|
210
|
+
|
|
211
|
+
// should not loadOptions since not scrolled to bottom
|
|
212
|
+
await waitFor(() => {
|
|
213
|
+
expect(mockLoadOptions).toHaveBeenCalledTimes(initialCallCount);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
fireEvent.scroll(listbox, { target: { scrollTop: 400 } });
|
|
217
|
+
|
|
218
|
+
await waitFor(() => {
|
|
219
|
+
expect(mockLoadOptions).toHaveBeenCalledTimes(initialCallCount + 1);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test('should call loadOptions if more options available and not enough options for scroll', async () => {
|
|
224
|
+
const mockLoadOptions = jest.fn(loadOptions);
|
|
225
|
+
const client = new QueryClient();
|
|
226
|
+
|
|
227
|
+
render(
|
|
228
|
+
<QueryClientProvider client={client}>
|
|
229
|
+
<AsyncAutocomplete
|
|
230
|
+
queryKey="test-loadOptions-noscroll"
|
|
231
|
+
loadOptions={mockLoadOptions}
|
|
232
|
+
limit={5}
|
|
233
|
+
FieldProps={{ label: 'Test' }}
|
|
234
|
+
/>
|
|
235
|
+
</QueryClientProvider>
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const input = screen.getByRole('combobox');
|
|
239
|
+
fireEvent.click(input);
|
|
240
|
+
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
|
241
|
+
|
|
242
|
+
await waitFor(() => {
|
|
243
|
+
expect(mockLoadOptions).toHaveBeenCalled();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// should load more options until enough options for scroll or no more options to load
|
|
247
|
+
const listbox = await screen.findByRole('listbox');
|
|
248
|
+
Object.defineProperty(listbox, 'scrollHeight', { value: 500, writable: true });
|
|
249
|
+
Object.defineProperty(listbox, 'clientHeight', { value: 100, writable: true });
|
|
250
|
+
Object.defineProperty(listbox, 'scrollTop', { value: 0, writable: true });
|
|
251
|
+
|
|
252
|
+
await waitFor(() => expect(() => screen.getByAltText('Loading')).toThrow());
|
|
253
|
+
|
|
254
|
+
// count number of calls before satisfying scrollable condition
|
|
255
|
+
const maxCallCount = mockLoadOptions.mock.calls.length;
|
|
256
|
+
|
|
257
|
+
fireEvent.pointerEnter(listbox);
|
|
258
|
+
|
|
259
|
+
// should not fallback to load more options as scrollable condition is satisfied
|
|
260
|
+
await waitFor(() => {
|
|
261
|
+
expect(mockLoadOptions).toHaveBeenCalledTimes(maxCallCount);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
242
265
|
|
|
243
266
|
test('should search with input value', async () => {
|
|
244
267
|
const mockLoadOptions = jest.fn(async () => ({ options: [{ label: 'Option 1' }], hasMore: false, offset: 50 }));
|
|
@@ -112,7 +112,7 @@ export const AsyncAutocomplete = <
|
|
|
112
112
|
const difference = listboxNode.scrollHeight - (listboxNode.scrollTop + listboxNode.clientHeight);
|
|
113
113
|
|
|
114
114
|
// Only fetch if we are near the bottom, not already fetching, and there are more results
|
|
115
|
-
if (difference <=
|
|
115
|
+
if (difference <= 10 && !isLoading && !isFetching && hasNextPage) {
|
|
116
116
|
fetchNextPage();
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -142,7 +142,7 @@ export const AsyncAutocomplete = <
|
|
|
142
142
|
...ListboxProps,
|
|
143
143
|
ref: setListboxRef,
|
|
144
144
|
onScroll: handleAddingOptions,
|
|
145
|
-
onPointerEnter: handleAddingOptions
|
|
145
|
+
onPointerEnter: handleAddingOptions
|
|
146
146
|
}}
|
|
147
147
|
/>
|
|
148
148
|
);
|
|
@@ -31,7 +31,7 @@ const languages = [
|
|
|
31
31
|
];
|
|
32
32
|
|
|
33
33
|
const meta: Meta<typeof Autocomplete> = {
|
|
34
|
-
title: 'Form Components/
|
|
34
|
+
title: 'Form Components/Uncontrolled Fields/Autocomplete',
|
|
35
35
|
component: Autocomplete,
|
|
36
36
|
tags: ['autodocs'],
|
|
37
37
|
args: {
|
|
@@ -72,7 +72,7 @@ export const _Multi: StoryObj<typeof Autocomplete> = {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
/** Notice the new `read-only` styling. We're moving away from `disabled` in favor of `read-only`.
|
|
75
|
-
* _See the [Disabled Fields Explainer](./?path=/docs/bs4-migration-form-migration--disabled-fields) for more information on when to use each._
|
|
75
|
+
* _See the [Disabled Fields Explainer](./?path=/docs/upgrading/bs4-migration-form-migration--disabled-fields) for more information on when to use each._
|
|
76
76
|
*/
|
|
77
77
|
export const _States: StoryObj<typeof Autocomplete> = {
|
|
78
78
|
render: (args) => (
|
|
@@ -196,7 +196,7 @@ export const _Grouped: StoryObj<typeof Autocomplete> = {
|
|
|
196
196
|
},
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
/** Wrap the fields in a `SearchByFormGroup` from the [@availity/mui-form-utils](./?path=/docs/form-components-formutils-
|
|
199
|
+
/** Wrap the fields in a `SearchByFormGroup` from the [@availity/mui-form-utils](./?path=/docs/form-components-uncontrolled-formutils-readme--docs) package for our combined search by styles.
|
|
200
200
|
*
|
|
201
201
|
* The "Search By" field id must be passed as the FormGroup supplies the label.
|
|
202
202
|
*/
|
|
@@ -5,7 +5,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
5
5
|
import { CodesAutocomplete } from './CodesAutocomplete';
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof CodesAutocomplete> = {
|
|
8
|
-
title: 'Form Components/
|
|
8
|
+
title: 'Form Components/Uncontrolled Fields/CodesAutocomplete',
|
|
9
9
|
component: CodesAutocomplete,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
11
|
args: {
|
|
@@ -5,7 +5,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
5
5
|
import { OrganizationAutocomplete } from './OrganizationAutocomplete';
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof OrganizationAutocomplete> = {
|
|
8
|
-
title: 'Form Components/
|
|
8
|
+
title: 'Form Components/Uncontrolled Fields/OrganizationAutocomplete',
|
|
9
9
|
component: OrganizationAutocomplete,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
11
|
args: {
|
|
@@ -5,7 +5,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
5
5
|
import { ProviderAutocomplete } from './ProviderAutocomplete';
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof ProviderAutocomplete> = {
|
|
8
|
-
title: 'Form Components/
|
|
8
|
+
title: 'Form Components/Uncontrolled Fields/ProviderAutocomplete',
|
|
9
9
|
component: ProviderAutocomplete,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
11
|
args: {
|