@mackin.com/styleguide 9.2.1 → 9.2.4

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.
Files changed (2) hide show
  1. package/index.js +18 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1012,21 +1012,24 @@ const Autocomplete = (p) => {
1012
1012
  listBorderRadius = theme.controls.borderRadius || '0.5rem';
1013
1013
  }
1014
1014
  const onPickValue = (v) => {
1015
- p.onPick(v);
1016
- // wait for the re-render. the value will not update if the control has focus
1015
+ var _a;
1016
+ // the TextInput will not respond to outer value changes if it has focus.
1017
+ // here we clear first and then onPickValue will re-focus after all updates.
1018
+ (_a = input.current) === null || _a === void 0 ? void 0 : _a.blur();
1017
1019
  setTimeout(() => {
1018
- var _a;
1019
- (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
1020
+ // blur is now complete
1021
+ p.onPick(v);
1022
+ // wait for the re-render. the value will not update if the control has focus
1023
+ setTimeout(() => {
1024
+ var _a;
1025
+ (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
1026
+ }, 0);
1020
1027
  }, 0);
1021
1028
  };
1022
1029
  return (React__namespace.createElement("div", { onClick: e => {
1023
1030
  e.stopPropagation();
1024
1031
  }, onKeyDown: e => {
1025
- var _a;
1026
1032
  if (e.key === 'Escape') {
1027
- // the TextInput will not respond to outer value changes if it has focus.
1028
- // here we clear first and then onPickValue will re-focus after all updates.
1029
- (_a = input.current) === null || _a === void 0 ? void 0 : _a.blur();
1030
1033
  onPickValue(undefined);
1031
1034
  }
1032
1035
  }, ref: element, className: css.cx(css.css({
@@ -1087,6 +1090,9 @@ const Autocomplete = (p) => {
1087
1090
  (_b = getNextTabElement(listItemIndex, -1)) === null || _b === void 0 ? void 0 : _b.focus();
1088
1091
  }
1089
1092
  else if (e.key === 'Enter') {
1093
+ e.stopPropagation();
1094
+ // this will prevent the click event from firing in addition to this enter key event.
1095
+ e.preventDefault();
1090
1096
  onPickValue(v);
1091
1097
  }
1092
1098
  }, className: css.cx(buttonMarkerClass + listItemIndex, css.css({
@@ -4758,7 +4764,11 @@ class AutocompleteEntityController {
4758
4764
  return this._options.map(o => o.name);
4759
4765
  }
4760
4766
  async onChange(newValue) {
4767
+ const clearEntity = newValue !== this._ctrl.value;
4761
4768
  await this._ctrl.onChange(newValue);
4769
+ if (clearEntity) {
4770
+ this._pickedEntity = undefined;
4771
+ }
4762
4772
  this.trySyncCtrlOptions();
4763
4773
  }
4764
4774
  onPick(newValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "9.2.1",
3
+ "version": "9.2.4",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",