Skip to content

Commit

Permalink
fix(@leav/ui): value disappearing on blur on advanced field
Browse files Browse the repository at this point in the history
  • Loading branch information
philippechevieux authored and renaudAmsellem committed Oct 31, 2024
1 parent 0a4efa6 commit cf60107
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe('AttributeStandardRepo', () => {
_id: 'core_values/987654',
_rev: '_WSywvyC--_',
_key: 987654,
payload: 'test_val'
value: 'test_val'
};

const savedEdgeData = {
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('AttributeStandardRepo', () => {
_id: 'core_values/987654',
_rev: '_WSywvyC--_',
_key: 987654,
payload: 'test_val',
value: 'test_val',
version: {
my_tree: '1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand All @@ -279,7 +273,6 @@ function StandardFieldValue({
}

await onDelete(fieldValue.idValue);
_uneditField();
};

const _handleFocus = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ export const StandardFieldValueDisplayHandler: FunctionComponent<IStandardFieldV
});
};

const _handleBlur = () => {
const _handleBlur = () =>
dispatch({
type: StandardFieldReducerActionsTypes.CANCEL_EDITING,
idValue: fieldValue.idValue
});
};

const commonProps = {
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export const StandardFieldValueRead: FunctionComponent<IStandardFieldValueReadPr
onClick(e);
};

let displayValue = String(fieldValue.value?.payload ?? '');
let displayValue = String(fieldValue.value?.payload ?? fieldValue.displayValue ?? '');

let width = '100%';
switch (state.attribute.format) {
case AttributeFormat.date_range:
Expand Down

0 comments on commit cf60107

Please sign in to comment.