From cf60107b3734ea598cef7003fbe2fa59d5f68dd0 Mon Sep 17 00:00:00 2001 From: Philippe Chevieux Date: Wed, 30 Oct 2024 09:19:59 +0100 Subject: [PATCH] fix(@leav/ui): value disappearing on blur on advanced field --- .../infra/attributeTypes/attributeAdvancedRepo.spec.ts | 4 ++-- .../src/infra/attributeTypes/attributeAdvancedRepo.ts | 2 +- .../StandardFieldValue/StandardFieldValue.tsx | 9 +-------- .../StandardFieldValueDisplayHandler.tsx | 3 +-- .../StandardFieldValueRead/StandardFieldValueRead.tsx | 3 ++- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.spec.ts b/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.spec.ts index e3f13eb34..ffb5ed625 100644 --- a/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.spec.ts +++ b/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.spec.ts @@ -176,7 +176,7 @@ describe('AttributeStandardRepo', () => { _id: 'core_values/987654', _rev: '_WSywvyC--_', _key: 987654, - payload: 'test_val' + value: 'test_val' }; const savedEdgeData = { @@ -242,7 +242,7 @@ describe('AttributeStandardRepo', () => { _id: 'core_values/987654', _rev: '_WSywvyC--_', _key: 987654, - payload: 'test_val', + value: 'test_val', version: { my_tree: '1' } diff --git a/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.ts b/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.ts index dbd5c151b..0f4ab0b12 100644 --- a/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.ts +++ b/apps/core/src/infra/attributeTypes/attributeAdvancedRepo.ts @@ -149,7 +149,7 @@ export default function ({ const res: IValue = { id_value: savedVal._key, - payload: savedVal.payload, + payload: savedVal.value, attribute: savedEdge.attribute, modified_at: savedEdge.modified_at, created_at: savedEdge.created_at, diff --git a/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.tsx b/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.tsx index f47941c16..4ff97151f 100644 --- a/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.tsx +++ b/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.tsx @@ -244,19 +244,13 @@ function StandardFieldValue({ } }, [fieldValue.isEditing, fieldValue.editingValue]); - const _uneditField = () => { - dispatch({ - type: StandardFieldReducerActionsTypes.CANCEL_EDITING, - idValue: fieldValue.idValue - }); - }; - const _handleSubmit = async (valueToSave: StandardValueTypes, id?: string) => { if (valueToSave === '') { return _handleDelete(); } const convertedValue = typeof valueToSave === 'object' ? JSON.stringify(valueToSave) : valueToSave; + await onSubmit(fieldValue.idValue, convertedValue); }; @@ -279,7 +273,6 @@ function StandardFieldValue({ } await onDelete(fieldValue.idValue); - _uneditField(); }; const _handleFocus = () => { diff --git a/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueDisplayHandler.tsx b/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueDisplayHandler.tsx index 23fcb47a5..c86dc5dd3 100644 --- a/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueDisplayHandler.tsx +++ b/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueDisplayHandler.tsx @@ -54,12 +54,11 @@ export const StandardFieldValueDisplayHandler: FunctionComponent { + const _handleBlur = () => dispatch({ type: StandardFieldReducerActionsTypes.CANCEL_EDITING, idValue: fieldValue.idValue }); - }; const commonProps = { state, diff --git a/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueRead/StandardFieldValueRead.tsx b/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueRead/StandardFieldValueRead.tsx index f84ce8276..499bed09a 100644 --- a/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueRead/StandardFieldValueRead.tsx +++ b/libs/ui/src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValueDisplayHandler/StandardFieldValueRead/StandardFieldValueRead.tsx @@ -112,7 +112,8 @@ export const StandardFieldValueRead: FunctionComponent