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

🐛Fix: keep event draft during save process #181

Closed
wants to merge 5 commits into from

Conversation

murilo9
Copy link
Contributor

@murilo9 murilo9 commented Dec 10, 2024

This fixes #145

What I've done:

  • Added code from this POC.
  • The POC's code managed to preserve the draft during save, but once I clicked on a different grid position to create a new event, it created a draft with the previous values and position.
  • To fix the above issue, I changed Draft.tsx:useEffect's logic to sync preservedDraft with draft when isProcessing is false.
  • All automated tests have passed.

How I've tested this fix:

  1. Clicked on a random position on the grid, and checked if event form opens.
  2. Clicked outside the event form, and checked if event form closes, and the draft was gone.
  3. CLicked on a new random position in the grid, and checked if event form opens.
  4. Added event title and time, then clicked Save. CHecked that draft got preserved during save process.
  5. Clicked on a new random position in the grid, and checked if a new draft was created in the correct position, with the event form propperly filled.

Copy link
Contributor

@tyler-dane tyler-dane left a comment

Choose a reason for hiding this comment

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

Hey @murilo9, I'm afraid the current state of this PR would do more harm than good due to the following issues I'm seeing

  1. When creating a new timed event, the title flashes indefinitely. This doesn't happen every time, but often enough.
new.flash.mov
  1. The form now stays open until the frontend receives a response from the backend. Previously, the form closed immediately. This delay causes a user to question whether they clicked the Save button.
  2. Clicking the empty space in the all-day row results in the event rectangle rendering, but not the form. Clicking the empty rectangle will then open the form. (This is occasional and may not be caused by this PR).

Please spend a little time considering if there's a way we can change our approach to fix these issues without having to do a big refactor. If not, I'd rather put this issue on hold until after cleaning up our state management than introduce more bugs.

if (preservedDraft && !isDrafting && !isProcessing) {
return null;
}
if (!preservedDraft && !draft) return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This effect is probably what's getting us into trouble. But I'm wondering if draft is changing too frequently for this copied preservedDraft to stay in sync

@murilo9
Copy link
Contributor Author

murilo9 commented Dec 11, 2024

Regarding no. 1 and 3, I'll give a look on them. For no. 2, may I add a loading state to the Save button (disable the button and change its text to "Saving...")?

@tyler-dane
Copy link
Contributor

Adding a pending message ('Saving...') and disabling the button would mitigate confusion. But that's still a step backward compared to how it works now since we'd still be forcing the user to wait for the operation to finish.

I'd rather focus on getting the event rectangle to always show without any strings attached.

We could add some non-blocking pending state to show that the background operation is still processing as part of another enhancement.

@murilo9
Copy link
Contributor Author

murilo9 commented Dec 13, 2024

I thikn I don't really understand the logic of Draft.ts yet, especially what makes it (re)render, the purpose of its variables (isDrafting, isProcessing, isLoadingDom, draft vs preservedDraft) and the effects of each combination of values for those variables. I'm afraid I'll have to give up on this issue for now and try another that I have a better chance to finish before the end of this week 😞

@tyler-dane
Copy link
Contributor

OK, appreciate the honesty. I'm going to close this so we can focus on other issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keep new event on grid during save
2 participants