From 31bef89a605f65f98c0e2d03aeb5cdeff3a6dd4f Mon Sep 17 00:00:00 2001 From: hujiahao-hjh Date: Tue, 27 Jul 2021 17:29:34 +0800 Subject: [PATCH 1/2] fix: issue edit datepicker bug --- shell/app/common/components/edit-field.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/shell/app/common/components/edit-field.tsx b/shell/app/common/components/edit-field.tsx index 7a249126da..b8504f9fff 100644 --- a/shell/app/common/components/edit-field.tsx +++ b/shell/app/common/components/edit-field.tsx @@ -271,12 +271,6 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => { break; } - const onClick = () => { - if (!editMode && ((type && !['dateReadonly', 'readonly'].includes(type)) || !type)) { - updater.editMode(false); - } - }; - return (
{label && ( @@ -292,7 +286,7 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => { {label}
)} -
+
{Comp} {suffix}
From 294c59e1c36e8cf9a9461dac30e53bac4c0334a9 Mon Sep 17 00:00:00 2001 From: hujiahao-hjh Date: Tue, 27 Jul 2021 19:06:11 +0800 Subject: [PATCH 2/2] fix: delete useless code --- shell/app/common/__tests__/components/edit-field.test.tsx | 1 - shell/app/common/components/edit-field.tsx | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/shell/app/common/__tests__/components/edit-field.test.tsx b/shell/app/common/__tests__/components/edit-field.test.tsx index ff6838b3bc..15b6c31c65 100644 --- a/shell/app/common/__tests__/components/edit-field.test.tsx +++ b/shell/app/common/__tests__/components/edit-field.test.tsx @@ -64,7 +64,6 @@ describe('EditField', () => { expect(changeFn).toHaveBeenCalledTimes(1); wrapper.find('input').simulate('blur'); expect(changeCbFn).toHaveBeenLastCalledWith({ name: 'erda cloud' }); - expect(wrapper.find('.edit-comp-text')).toExist(); // wrapper.find('.edit-comp-text').simulate('click'); // wrapper.update(); // console.log(wrapper.find('.common-edit-field').html()); diff --git a/shell/app/common/components/edit-field.tsx b/shell/app/common/components/edit-field.tsx index b8504f9fff..b4b3f8e540 100644 --- a/shell/app/common/components/edit-field.tsx +++ b/shell/app/common/components/edit-field.tsx @@ -140,10 +140,9 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => { }); const [state, updater] = useUpdate({ - editMode: false, editValue: undefined as unknown as string, }); - const { editMode, editValue } = state; + const { editValue } = state; React.useEffect(() => { updater.editValue(value || get(data, name)); @@ -164,7 +163,6 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => { if (onChangeCb) { onChangeCb(set({}, name, v)); } - updater.editMode(true); }; const onBlur = (v?: string, fieldType?: string) => { @@ -176,7 +174,6 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => { onChangeCb(set({}, name, v), fieldType); } } - updater.editMode(true); }; switch (type) { case 'select': { @@ -286,7 +283,7 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => { {label}
)} -
+
{Comp} {suffix}