Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit 7cd3a14

Browse files
Merge pull request #61 from inrupt/feature/fix-delete-fields-by-name
Fixed delete by field name
2 parents b69a0d2 + 487e19f commit 7cd3a14

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib/hooks/useShex.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ export const useShex = (fileShex: String, documentUri: String, rootShape: String
310310

311311
if (newExpressions[i]._formValues[y]._formFocus.name === options.key) {
312312
if (action === 'delete') {
313-
// If field is the last one will keep it but will update value and name
314-
let toIndex = newExpressions[i]._formValues.length === 1 ? 1 : 0;
313+
const _formValues = newExpressions[i]._formValues;
314+
const currentFieldName = newExpressions[i]._formValues[y]._formFocus.name;
315315

316-
newExpressions[i]._formValues.splice(y, y + toIndex);
316+
newExpressions[i]._formValues = _formValues.filter(val => val._formFocus.name !== currentFieldName);
317317

318318
} else {
319319
newExpressions[i]._formValues[y] = {

0 commit comments

Comments
 (0)