@onehat/ui 0.4.31 → 0.4.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.4.31",
3
+ "version": "0.4.32",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -65,6 +65,7 @@ export function ComboComponent(props) {
65
65
  onGridAdd, // to hook into when menu adds (ComboEditor only)
66
66
  onGridSave, // to hook into when menu saves (ComboEditor only)
67
67
  onGridDelete, // to hook into when menu deletes (ComboEditor only)
68
+ onSubmit, // when Combo is used in a Tag, call this when the user submits the Combo value (i.e. presses Enter or clicks a row)
68
69
  newEntityDisplayProperty,
69
70
  testID,
70
71
 
@@ -252,6 +253,9 @@ export function ComboComponent(props) {
252
253
  if (id !== value) {
253
254
  setValue(id);
254
255
  }
256
+ if (onSubmit) {
257
+ onSubmit(id);
258
+ }
255
259
  hideMenu();
256
260
  break;
257
261
  case 'ArrowDown':
@@ -815,6 +819,9 @@ export function ComboComponent(props) {
815
819
  hideMenu();
816
820
  onInputFocus();
817
821
  }
822
+ if (onSubmit) {
823
+ onSubmit(id);
824
+ }
818
825
  }}
819
826
  reference="grid"
820
827
  parent={self}
@@ -50,13 +50,6 @@ function TagComponent(props) {
50
50
  } = props,
51
51
  styles = UiGlobals.styles,
52
52
  valueRef = useRef(value),
53
- ignoreNextComboValueChangeRef = useRef(false),
54
- getIgnoreNextComboValueChange = () => {
55
- return ignoreNextComboValueChangeRef.current;
56
- },
57
- setIgnoreNextComboValueChange = (bool) => {
58
- ignoreNextComboValueChangeRef.current = bool;
59
- },
60
53
  onView = async (item, e) => {
61
54
  const
62
55
  id = item.id,
@@ -91,14 +84,9 @@ function TagComponent(props) {
91
84
  });
92
85
  },
93
86
  clearComboValue = () => {
94
- setIgnoreNextComboValueChange(true); // we're clearing out the value of the underlying Combo, so ignore it when this combo submits the new value change
95
87
  self.children.combo.setValue(null);
96
88
  },
97
89
  onChangeComboValue = (comboValue) => {
98
- if (getIgnoreNextComboValueChange()) {
99
- setIgnoreNextComboValueChange(false);
100
- return;
101
- }
102
90
 
103
91
  if (_.isNil(comboValue)) {
104
92
  // NOTE: We *shouldn't* get here, but for some unknown reason, we *were* getting here on rare occasions.
@@ -309,21 +297,22 @@ function TagComponent(props) {
309
297
  >
310
298
  <HStack className={valueBoxesClassName}>{valueBoxes}</HStack>
311
299
 
312
- {!isViewOnly && <WhichCombo
313
- Repository={props.Repository}
314
- Editor={props.Editor}
315
- onChangeValue={onChangeComboValue}
316
- parent={self}
317
- reference="combo"
318
- isInTag={true}
319
- onGridAdd={onGridAdd}
320
- onGridSave={onGridSave}
321
- onGridDelete={onGridDelete}
322
- tooltip={tooltip}
323
- usePermissions={props.usePermissions}
324
- {..._combo}
325
- className={comboClassName}
326
- />}
300
+ {!isViewOnly &&
301
+ <WhichCombo
302
+ Repository={props.Repository}
303
+ Editor={props.Editor}
304
+ onSubmit={onChangeComboValue}
305
+ parent={self}
306
+ reference="combo"
307
+ isInTag={true}
308
+ onGridAdd={onGridAdd}
309
+ onGridSave={onGridSave}
310
+ onGridDelete={onGridDelete}
311
+ tooltip={tooltip}
312
+ usePermissions={props.usePermissions}
313
+ {..._combo}
314
+ className={comboClassName}
315
+ />}
327
316
  </VStackNative>;
328
317
 
329
318
  }
@@ -20,8 +20,7 @@ export default function withValue(WrappedComponent) {
20
20
  return <WrappedComponent {...props} ref={ref} />;
21
21
  }
22
22
 
23
- const
24
- {
23
+ const {
25
24
  onChangeValue,
26
25
  value,
27
26
  startingValue = null,