Skip to content

Commit

Permalink
fix: issue edit datepicker bug (erda-project#761)
Browse files Browse the repository at this point in the history
* fix: issue edit datepicker bug

* fix: delete useless code
  • Loading branch information
hujiahao-hjh authored and erda-bot committed Jul 27, 2021
1 parent 13ca683 commit 8edc105
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
1 change: 0 additions & 1 deletion shell/app/common/__tests__/components/edit-field.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
13 changes: 2 additions & 11 deletions shell/app/common/components/edit-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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) => {
Expand All @@ -176,7 +174,6 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => {
onChangeCb(set({}, name, v), fieldType);
}
}
updater.editMode(true);
};
switch (type) {
case 'select': {
Expand Down Expand Up @@ -271,12 +268,6 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => {
break;
}

const onClick = () => {
if (!editMode && ((type && !['dateReadonly', 'readonly'].includes(type)) || !type)) {
updater.editMode(false);
}
};

return (
<div className={`common-edit-field ${className}`}>
{label && (
Expand All @@ -291,7 +282,7 @@ export const EditField = React.forwardRef((props: IProps, _compRef) => {
{label}
</div>
)}
<div onClick={onClick} className={classnames({ 'edit-comp-text': editMode })}>
<div>
{Comp}
{suffix}
</div>
Expand Down

0 comments on commit 8edc105

Please # to comment.