@jobber/components 6.103.4-uncontroll-951d07b.6 → 6.103.4-uncontroll-3a6b89f.8

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.
@@ -359,9 +359,8 @@ function useAutocomplete(props) {
359
359
  // This is only options
360
360
  const optionCount = renderable.reduce((count, item) => count + (item.kind === "option" ? 1 : 0), 0);
361
361
  const hasSelection = React.useMemo(() => {
362
- var _a;
363
362
  if (multiple) {
364
- const current = (_a = value) !== null && _a !== void 0 ? _a : [];
363
+ const current = value !== null && value !== void 0 ? value : [];
365
364
  return Array.isArray(current) && current.length > 0;
366
365
  }
367
366
  return value != null;
@@ -420,10 +419,11 @@ function useAutocomplete(props) {
420
419
  // (not from internal state sync when parent changes the value prop)
421
420
  // This prevents calling onChange when we're syncing state from a controlled value prop,
422
421
  // but still allows onChange to fire when the user deletes the input text
423
- if (lastInputWasUser.current && hasSelection) {
422
+ const currentlyHasSelection = value != null;
423
+ if (lastInputWasUser.current && currentlyHasSelection) {
424
424
  onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
425
425
  }
426
- }, [inputValue, multiple, hasSelection, setActiveIndex, onChange, open]);
426
+ }, [inputValue, multiple, setActiveIndex, onChange, open, value]);
427
427
  function selectOption(option) {
428
428
  var _a;
429
429
  if (multiple) {
@@ -357,9 +357,8 @@ function useAutocomplete(props) {
357
357
  // This is only options
358
358
  const optionCount = renderable.reduce((count, item) => count + (item.kind === "option" ? 1 : 0), 0);
359
359
  const hasSelection = useMemo(() => {
360
- var _a;
361
360
  if (multiple) {
362
- const current = (_a = value) !== null && _a !== void 0 ? _a : [];
361
+ const current = value !== null && value !== void 0 ? value : [];
363
362
  return Array.isArray(current) && current.length > 0;
364
363
  }
365
364
  return value != null;
@@ -418,10 +417,11 @@ function useAutocomplete(props) {
418
417
  // (not from internal state sync when parent changes the value prop)
419
418
  // This prevents calling onChange when we're syncing state from a controlled value prop,
420
419
  // but still allows onChange to fire when the user deletes the input text
421
- if (lastInputWasUser.current && hasSelection) {
420
+ const currentlyHasSelection = value != null;
421
+ if (lastInputWasUser.current && currentlyHasSelection) {
422
422
  onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
423
423
  }
424
- }, [inputValue, multiple, hasSelection, setActiveIndex, onChange, open]);
424
+ }, [inputValue, multiple, setActiveIndex, onChange, open, value]);
425
425
  function selectOption(option) {
426
426
  var _a;
427
427
  if (multiple) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.103.4-uncontroll-951d07b.6+951d07b93",
3
+ "version": "6.103.4-uncontroll-3a6b89f.8+3a6b89f05",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -538,5 +538,5 @@
538
538
  "> 1%",
539
539
  "IE 10"
540
540
  ],
541
- "gitHead": "951d07b936bd3e0cc6dc48c9a4cb98f2a93a838e"
541
+ "gitHead": "3a6b89f051c7bf248c95263b514cd02722010dd7"
542
542
  }