Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove react hook form in send email action #9130

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Dec 18, 2024

  • remove react hook form
  • put back multiline for body

@thomtrp thomtrp marked this pull request as ready for review December 18, 2024 16:36
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Simplified form management in WorkflowEditActionFormSendEmail by removing react-hook-form dependency in favor of native React state management.

  • Replaced complex form controllers with useState hook in /packages/twenty-front/src/modules/workflow/workflow-actions/components/WorkflowEditActionFormSendEmail.tsx
  • Added multiline support to email body field via FormTextFieldInput component
  • Implemented handleFieldChange function for direct form state updates
  • Streamlined form submission with debounced save action

1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 79 to 85
setFormData({
connectedAccountId: action.settings.input.connectedAccountId,
email: action.settings.input.email,
subject: action.settings.input.subject ?? '',
body: action.settings.input.body ?? '',
});
}, [action.settings.input]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm not sure if we need this useEffect. If the server takes time to respond, the form's state might be corrupted.

Copy link
Contributor

@Devessier Devessier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good! Thank you for taking this bug. I would like us to delete the useEffect we used to synchronize the local state with the backend state. It's primarily dead code, and it's simpler not to override the local state with the backend state for now.

Comment on lines 78 to 85
useEffect(() => {
form.setValue(
'connectedAccountId',
action.settings.input.connectedAccountId ?? '',
);
form.setValue('email', action.settings.input.email ?? '');
form.setValue('subject', action.settings.input.subject ?? '');
form.setValue('body', action.settings.input.body ?? '');
}, [action.settings, form]);
setFormData({
connectedAccountId: action.settings.input.connectedAccountId,
email: action.settings.input.email,
subject: action.settings.input.subject ?? '',
body: action.settings.input.body ?? '',
});
}, [action.settings.input]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing this, I would remove the useEffect. We built the form field inputs with a defaultValue in mind, not a controlled value. Technically, our abstractions don't allow us to set the value of TipTap editors.

This useEffect has no effect, at least for form fields. The connected account select is a controlled component, and this useEffect would set its value. I think it's better to consider that the back-end state doesn't override the local state. We'll see how we can handle it properly if that's okay with you. Preventing the local override makes the experience on a slow network better. I prefer not to override what people might have typed in inputs to display the fresher data coming from the backend.

Copy link
Contributor

@martmull martmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Baptiste comment, I still approve

@thomtrp thomtrp force-pushed the tt-fix-send-email-multiline branch from 9870ea2 to 12aacd1 Compare December 19, 2024 09:34
Copy link
Contributor

@Devessier Devessier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you.

@thomtrp thomtrp enabled auto-merge (squash) December 19, 2024 09:44
@thomtrp thomtrp merged commit 32fef06 into main Dec 19, 2024
22 checks passed
@thomtrp thomtrp deleted the tt-fix-send-email-multiline branch December 19, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants