@onehat/ui 0.2.40 → 0.2.41

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.2.40",
3
+ "version": "0.2.41",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import { useState, } from 'react';
1
+ import { useEffect, useState, } from 'react';
2
2
  import {
3
3
  EDITOR_MODE__VIEW,
4
4
  EDITOR_MODE__ADD,
@@ -141,6 +141,18 @@ export default function withEditor(WrappedComponent) {
141
141
  setIsEditorShown(false);
142
142
  };
143
143
 
144
+ useEffect(() => {
145
+ if (selection.length === 1 && selection.isPhantom && userCanEdit) {
146
+ if (editorMode !== EDITOR_MODE__ADD) {
147
+ setEditorMode(EDITOR_MODE__ADD);
148
+ }
149
+ } else {
150
+ if (editorMode !== EDITOR_MODE__VIEW) {
151
+ setEditorMode(EDITOR_MODE__VIEW);
152
+ }
153
+ }
154
+ }, [selection]);
155
+
144
156
  return <WrappedComponent
145
157
  {...props}
146
158
  currentRecord={currentRecord}