Skip to content

fix: improve SnackbarNotification cleanup#244

Open
priscila-moneo wants to merge 1 commit into
mainfrom
fix/remove-redundant-second-snackbar-message
Open

fix: improve SnackbarNotification cleanup#244
priscila-moneo wants to merge 1 commit into
mainfrom
fix/remove-redundant-second-snackbar-message

Conversation

@priscila-moneo
Copy link
Copy Markdown
Contributor

@priscila-moneo priscila-moneo commented May 19, 2026

ref: https://app.clickup.com/t/86b9y6h89

Rationale

Previously, the SnackbarNotification component sometimes rendered a second, empty snackbar (with only the icon) after the intended message disappeared. This was caused by the cleanup logic: when the snackbar message was cleared, the component briefly rendered with empty content before unmounting, due to the timing of state updates and the use of setTimeout.

This change improves the cleanup flow by leveraging the Snackbar’s onExited event, which fires only after the exit animation completes (either after autoHideDuration or manual close). Now, the message state is cleared only after the snackbar is fully closed, preventing any intermediate render with empty content. This ensures a smoother user experience and eliminates redundant or empty snackbar displays.

Summary by CodeRabbit

  • Improvements
    • Enhanced notification handling to ensure messages clear reliably after notifications finish transitioning out.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

SnackbarNotification's cleanup lifecycle is refactored to clear state exclusively after the MUI Snackbar exits, rather than on close with a delayed timeout. The handleExited callback is wired to the Snackbar's onExited event to ensure cleanup occurs after the full transition completes.

Changes

Snackbar Lifecycle Refactoring

Layer / File(s) Summary
Event-driven snackbar exit handling
src/components/mui/SnackbarNotification/index.js
clearMessage is simplified to only clear Redux state and reset local msgData; onClose is reduced to closing the snackbar with setOpen(false), removing the prior setTimeout behavior; a new handleExited callback performs cleanup after the snackbar fully exits and is wired via the Snackbar's onExited prop.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • santipalenque
  • smarcet

Poem

🐰 A snackbar's journey, once muddled by time,
Now waits for the exit—a moment sublime.
No rushing the cleanup, just let it flow free,
onExited ensures what the snack shall be.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: improving SnackbarNotification cleanup by refactoring lifecycle handling from setTimeout to the MUI Snackbar 'exited' event.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-redundant-second-snackbar-message

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.


const onClose = () => {
setOpen(false);
setTimeout(clearMessage, NOTIFICATION_TIMEOUT);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@priscila-moneo could u explain the rationale of this on the PR description ?

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.

@smarcet updated!

Copy link
Copy Markdown
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@priscila-moneo please review comments

Copy link
Copy Markdown
Contributor

@santipalenque santipalenque left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants