Skip to content

[TAN-7381] Undo button for single approve and add WarningModal for bulk approve/remove#13656

Open
AchrafGoVocal wants to merge 25 commits intomasterfrom
TAN-7381-unfo-approval-form-sync
Open

[TAN-7381] Undo button for single approve and add WarningModal for bulk approve/remove#13656
AchrafGoVocal wants to merge 25 commits intomasterfrom
TAN-7381-unfo-approval-form-sync

Conversation

@AchrafGoVocal
Copy link
Copy Markdown
Contributor

@AchrafGoVocal AchrafGoVocal commented Apr 17, 2026

Changelog

Added

  • [TAN-7381] Added a collapsible recently approved list to be able to undo recently approved ideas.

Changed

  • [TAN-7381] Added a confirmation modal when clicking on "Approve All' or "Remove All" in idea import.

For translators

@notion-workspace
Copy link
Copy Markdown

@cl-dev-bot
Copy link
Copy Markdown
Collaborator

cl-dev-bot commented Apr 17, 2026

Messages
📖 Changelog provided 🎉
📖 Notion issue: TAN-7381
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against 448b8af

@AchrafGoVocal AchrafGoVocal marked this pull request as ready for review April 20, 2026 06:45
@AchrafGoVocal AchrafGoVocal marked this pull request as draft April 20, 2026 12:00
@AchrafGoVocal AchrafGoVocal marked this pull request as ready for review April 21, 2026 08:41
Comment on lines 130 to 146
const autoSave = useCallback(
(id: string, formData: FormValues) => {
updateIdea({ id, requestBody: formData, skipRefetchCounts: true });
const { publication_status: _omit, ...rest } = formData;
updateIdea({ id, requestBody: rest, skipRefetchCounts: true });
},
[updateIdea]
);

useEffect(() => {
if (!ideaId || !(ideaId in ideaFormStatePerIdea)) return;

const timeout = setTimeout(() => {
autoSave(ideaId, ideaFormStatePerIdea[ideaId]);
}, 500);

return () => clearTimeout(timeout);
}, [ideaId, ideaFormStatePerIdea, autoSave]);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is a race condition that can happen here between when an idea is patched and when it is approved.
This is what I think happens:

  • Click an idea
  • The form mounts and quietly normalizes its values, which looks to react-hook-form like a form edit
  • That schedules a "save your edits" PATCH 500ms later
  • The PATCH ships the whole form, including publication_status: 'draft'.
    • If you click Approve just before that timer fires, the draft-PATCH lands right after the publish-PATCH and un-approves the idea.
    • This leads to a bug where an idea is both in the "Recently approved" list while also being in the "Ideas list"

That's why I remove the publication_status from the autoSave and also because it should only be updated by approving or undoing the approval.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sneaky! Nice catch! 💪

Copy link
Copy Markdown
Contributor

@amanda-anderson amanda-anderson left a comment

Choose a reason for hiding this comment

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

Code LGTM! 🚀 (I didn't do a functional review though - just let me know if you need that too!)

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.

3 participants