@via-profit/ui-kit 0.1.0-rc.96 → 0.1.0-rc.97

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.
@@ -173,9 +173,13 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
173
173
  react_1.default.useEffect(() => {
174
174
  if (JSON.stringify(items) !== JSON.stringify(itemsRef.current)) {
175
175
  itemsRef.current = items;
176
- dispatch((0, context_1.actionSetPartial)({ filteredItems: applyFilterForItems(inputValue, items) }));
176
+ const newFilteredItems = applyFilterForItems(inputValue, items);
177
+ dispatch((0, context_1.actionSetPartial)({ filteredItems: newFilteredItems }));
178
+ if (!newFilteredItems.length) {
179
+ onRequestClose();
180
+ }
177
181
  }
178
- }, [items, inputValue, applyFilterForItems, dispatch]);
182
+ }, [items, inputValue, applyFilterForItems, dispatch, onRequestClose]);
179
183
  react_1.default.useEffect(() => {
180
184
  const mouseDownEvent = (event) => {
181
185
  var _a;
@@ -194,8 +198,11 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
194
198
  const newInputValue = currentValue === null
195
199
  ? ''
196
200
  : selectedItemToString(currentValue);
201
+ const newFilteredItems = multiple
202
+ ? filteredItems
203
+ : applyFilterForItems(newInputValue, items);
197
204
  dispatch((0, context_1.actionSetPartial)({
198
- filteredItems: multiple ? filteredItems : applyFilterForItems(newInputValue, items),
205
+ filteredItems: newFilteredItems,
199
206
  inputValue: newInputValue,
200
207
  }));
201
208
  }
@@ -251,8 +258,9 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
251
258
  isFocusedRef.current = true;
252
259
  if (openOnFocus &&
253
260
  !currentOpen &&
254
- filteredItems.length > 0 &&
255
- inputValue.trim() !== '') {
261
+ filteredItems.length > 0
262
+ // && inputValue.trim() !== ''
263
+ ) {
256
264
  onRequestOpen(event);
257
265
  }
258
266
  if (!openOnFocus && !currentOpen && inputValue !== '' && filteredItems.length > 0) {
@@ -267,8 +275,9 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
267
275
  }
268
276
  if (isFocusedRef.current &&
269
277
  !currentOpen &&
270
- filteredItems.length > 0 &&
271
- inputValue.trim() !== '') {
278
+ filteredItems.length > 0
279
+ // && inputValue.trim() !== ''
280
+ ) {
272
281
  onRequestOpen(event);
273
282
  }
274
283
  }, onChange: event => {
@@ -284,14 +293,22 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
284
293
  onRequestOpen(event);
285
294
  }
286
295
  // console.debug('set filteredItems');
296
+ const newFilteredItems = applyFilterForItems(event.currentTarget.value, items);
297
+ if (newFilteredItems.length === 0 && currentOpen) {
298
+ onRequestClose();
299
+ }
300
+ if (newFilteredItems.length > 0 && !currentOpen) {
301
+ onRequestOpen(event);
302
+ }
287
303
  dispatch((0, context_1.actionSetPartial)({
288
- filteredItems: applyFilterForItems(event.currentTarget.value, items),
304
+ filteredItems: newFilteredItems,
289
305
  inputValue: event.currentTarget.value,
290
306
  }));
291
307
  } }))), [
292
308
  overridesMap,
293
309
  placeholder,
294
310
  label,
311
+ onRequestClose,
295
312
  error,
296
313
  requiredAsterisk,
297
314
  errorText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@via-profit/ui-kit",
3
- "version": "0.1.0-rc.96",
3
+ "version": "0.1.0-rc.97",
4
4
  "description": "UI Kit",
5
5
  "repository": {
6
6
  "type": "git",