@onehat/ui 0.3.149 → 0.3.150
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
|
@@ -40,6 +40,7 @@ function TagComponent(props) {
|
|
|
40
40
|
setValue,
|
|
41
41
|
...propsToPass // break connection between Tag and Combo props
|
|
42
42
|
} = props,
|
|
43
|
+
valueRef = useRef(value),
|
|
43
44
|
ignoreNextComboValueChangeRef = useRef(false),
|
|
44
45
|
[isViewerShown, setIsViewerShown] = useState(false),
|
|
45
46
|
[viewerSelection, setViewerSelection] = useState([]),
|
|
@@ -138,12 +139,13 @@ function TagComponent(props) {
|
|
|
138
139
|
});
|
|
139
140
|
setValue(newValue);
|
|
140
141
|
},
|
|
141
|
-
onGridAdd = (
|
|
142
|
+
onGridAdd = (selection) => {
|
|
142
143
|
// underlying GridEditor added a record.
|
|
143
144
|
// add it to this Tag's value
|
|
144
145
|
const
|
|
146
|
+
entity = selection[0],
|
|
145
147
|
id = entity.id,
|
|
146
|
-
newValue = _.clone(
|
|
148
|
+
newValue = _.clone(valueRef.current);
|
|
147
149
|
newValue.push({
|
|
148
150
|
id,
|
|
149
151
|
text: entity.displayValue,
|
|
@@ -153,14 +155,14 @@ function TagComponent(props) {
|
|
|
153
155
|
onGridSave = (selection) => {
|
|
154
156
|
// underlying GridEditor has changed a record.
|
|
155
157
|
// Check if that value exists, and if so, update its displayValue
|
|
156
|
-
if (_.isEmpty(
|
|
158
|
+
if (_.isEmpty(valueRef.current)) {
|
|
157
159
|
return;
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
const
|
|
161
163
|
entity = selection[0],
|
|
162
164
|
id = entity.id,
|
|
163
|
-
ix = _.findIndex(
|
|
165
|
+
ix = _.findIndex(valueRef.current, (item) => {
|
|
164
166
|
return item.id === id;
|
|
165
167
|
}),
|
|
166
168
|
isFound = ix !== -1;
|
|
@@ -168,7 +170,7 @@ function TagComponent(props) {
|
|
|
168
170
|
return;
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
const newValue = _.clone(
|
|
173
|
+
const newValue = _.clone(valueRef.current);
|
|
172
174
|
newValue[ix] = {
|
|
173
175
|
id,
|
|
174
176
|
text: entity.displayValue,
|
|
@@ -178,14 +180,14 @@ function TagComponent(props) {
|
|
|
178
180
|
onGridDelete = (selection) => {
|
|
179
181
|
// underlying GridEditor has deleted a value.
|
|
180
182
|
// Check if that value exists, and if so delete it
|
|
181
|
-
if (_.isEmpty(
|
|
183
|
+
if (_.isEmpty(valueRef.current)) {
|
|
182
184
|
return;
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
const
|
|
186
188
|
entity = selection[0],
|
|
187
189
|
id = entity.id,
|
|
188
|
-
ix = _.findIndex(
|
|
190
|
+
ix = _.findIndex(valueRef.current, (item) => {
|
|
189
191
|
return item.id === id;
|
|
190
192
|
}),
|
|
191
193
|
isFound = ix !== -1;
|
|
@@ -193,7 +195,7 @@ function TagComponent(props) {
|
|
|
193
195
|
return;
|
|
194
196
|
}
|
|
195
197
|
|
|
196
|
-
const newValue = _.filter(
|
|
198
|
+
const newValue = _.filter(valueRef.current, (item) => {
|
|
197
199
|
return item.id !== id;
|
|
198
200
|
});
|
|
199
201
|
setValue(newValue);
|
|
@@ -206,6 +208,8 @@ function TagComponent(props) {
|
|
|
206
208
|
onDelete={!isViewOnly ? () => onDelete(val) : null}
|
|
207
209
|
/>;
|
|
208
210
|
});
|
|
211
|
+
|
|
212
|
+
valueRef.current = value; // the onGrid* methods were dealing with stale data, so use a ref, and update it here
|
|
209
213
|
|
|
210
214
|
let WhichCombo = Combo;
|
|
211
215
|
if (_combo.isEditor) {
|