@onehat/ui 0.3.206 → 0.3.208

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.3.206",
3
+ "version": "0.3.208",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -125,6 +125,9 @@ function Form(props) {
125
125
  let skipAll = false;
126
126
  if (record?.isDestroyed) {
127
127
  skipAll = true; // if record is destroyed, skip render, but allow hooks to still be called
128
+ if (self?.parent?.parent?.setIsEditorShown) {
129
+ self.parent.parent.setIsEditorShown(false); // close the editor
130
+ }
128
131
  }
129
132
  const
130
133
  isMultiple = _.isArray(record),
@@ -37,6 +37,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
37
37
  onChange, // any kind of crud change
38
38
  onDelete,
39
39
  onSave, // this could also be called 'onEdit'
40
+ onEditorClose,
40
41
  newEntityDisplayValue,
41
42
  newEntityDisplayProperty, // in case the field to set for newEntityDisplayValue is different from model
42
43
  defaultValues,
@@ -66,10 +67,16 @@ export default function withEditor(WrappedComponent, isTree = false) {
66
67
  [currentRecord, setCurrentRecord] = useState(null),
67
68
  [isAdding, setIsAdding] = useState(false),
68
69
  [isSaving, setIsSaving] = useState(false),
69
- [isEditorShown, setIsEditorShown] = useState(false),
70
+ [isEditorShown, setIsEditorShownRaw] = useState(false),
70
71
  [isEditorViewOnly, setIsEditorViewOnly] = useState(canEditorViewOnly), // current state of whether editor is in view-only mode
71
72
  [isIgnoreNextSelectionChange, setIsIgnoreNextSelectionChange] = useState(false),
72
73
  [lastSelection, setLastSelection] = useState(),
74
+ setIsEditorShown = (bool) => {
75
+ setIsEditorShownRaw(bool);
76
+ if (!bool && onEditorClose) {
77
+ onEditorClose();
78
+ }
79
+ },
73
80
  setSelectionDecorated = (newSelection) => {
74
81
  function doIt() {
75
82
  setSelection(newSelection);
@@ -477,6 +484,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
477
484
  self.moveChildren = doMoveChildren;
478
485
  self.deleteChildren = doDeleteChildren;
479
486
  self.duplicate = doDuplicate;
487
+ self.setIsEditorShown = setIsEditorShown;
480
488
  }
481
489
  newEntityDisplayValueRef.current = newEntityDisplayValue;
482
490