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

Snackbar: Only allow action invoke once, Add button classes, Add ForceClose #8383

Merged
merged 4 commits into from
Mar 24, 2024

Conversation

danielchalmers
Copy link
Contributor

@danielchalmers danielchalmers commented Mar 16, 2024

Description

  • Limits the number of actions that can be performed to one so you can't keep triggering a snackbar that's fading away by checking State.UserHasInteracted.
  • Adds distinct classes to the action and close buttons along with updating tests to take advantage of that.
  • Adds Snackbar.ForceClose for instantly closing a snackbar in code without any animation and uses it in SnackbarTearDown for efficiency.
  • Small refactors on tests from other PR.

Resolves #8349

How Has This Been Tested?

unit, visually

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

So you can't keep clicking a snackbar that's fading away.

Also adds distinct classes to the snackbar's action and close buttons along with tweaking some existing tests to take advantage of that.

OnClickFromActionButtonOnlyOnce and OnClickFromBodyOnlyOnce are not functional yet

Resolves MudBlazor#8349
@github-actions github-actions bot added bug Something does not work as intended/expected enhancement New feature or request PR: needs review labels Mar 16, 2024
@danielchalmers danielchalmers marked this pull request as draft March 16, 2024 20:45
@danielchalmers danielchalmers changed the title Snackbar: Limit clicks to one time & Add button classes [need help with tests] Snackbar: Limit clicks to one time & Add button classes Mar 16, 2024
@danielchalmers danielchalmers changed the title [need help with tests] Snackbar: Limit clicks to one time & Add button classes Snackbar: Only allow invoking action once & Add classes to buttons Mar 22, 2024
@danielchalmers danielchalmers marked this pull request as ready for review March 23, 2024 01:23
@danielchalmers danielchalmers changed the title Snackbar: Only allow invoking action once & Add classes to buttons Snackbar: Only allow action invoke once, Add button classes, Add Snackbar.ForceClose Mar 23, 2024
@danielchalmers danielchalmers changed the title Snackbar: Only allow action invoke once, Add button classes, Add Snackbar.ForceClose Snackbar: Only allow action invoke once, Add button classes, Add ForceClose Mar 23, 2024
Copy link

codecov bot commented Mar 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.91%. Comparing base (345ec7c) to head (473bb59).
Report is 29 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #8383      +/-   ##
==========================================
+ Coverage   88.82%   88.91%   +0.08%     
==========================================
  Files         407      414       +7     
  Lines       12226    12301      +75     
  Branches     2441     2456      +15     
==========================================
+ Hits        10860    10937      +77     
+ Misses        834      832       -2     
  Partials      532      532              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@henon henon left a comment

Choose a reason for hiding this comment

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

ah, ah, ah, ah, stayin' alive ... I like it ;). I also like the occasional comments explaining non-intuitive code.

Just the busy-waiting while loop in teardown should be fixed. Otherwise looks good.

@ScarletKuro wanna do a second glance?

@danielchalmers
Copy link
Contributor Author

Just the busy-waiting while loop in teardown should be fixed. Otherwise looks good.

@henon Is it waiting? ForceClose immediately calls the OnClose event which should remove it from the service in one call.

@henon
Copy link
Collaborator

henon commented Mar 24, 2024

a while(true) without a sleep or task delay inside is by definition a busy-waiting loop. it loops as fast as it can until its break condition is finally met. it just wastes resources.

Edit: scrap that, I see now that it is not really waiting for anything.

@henon henon merged commit 9bb4af1 into MudBlazor:dev Mar 24, 2024
3 checks passed
@henon
Copy link
Collaborator

henon commented Mar 24, 2024

Thanks !

peterthorpe81 pushed a commit to peterthorpe81/MudBlazor that referenced this pull request Mar 25, 2024
…eClose (MudBlazor#8383)

* Snackbar: Limit clicks to one time & Add button classes

So you can't keep clicking a snackbar that's fading away.

Also adds distinct classes to the snackbar's action and close buttons along with tweaking some existing tests to take advantage of that.

OnClickFromActionButtonOnlyOnce and OnClickFromBodyOnlyOnce are not functional yet

Resolves MudBlazor#8349
@danielchalmers danielchalmers deleted the snackbarclickonce branch April 4, 2024 23:46
biegehydra pushed a commit to biegehydra/MudBlazor that referenced this pull request Apr 26, 2024
…eClose (MudBlazor#8383)

* Snackbar: Limit clicks to one time & Add button classes

So you can't keep clicking a snackbar that's fading away.

Also adds distinct classes to the snackbar's action and close buttons along with tweaking some existing tests to take advantage of that.

OnClickFromActionButtonOnlyOnce and OnClickFromBodyOnlyOnce are not functional yet

Resolves MudBlazor#8349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

You can invoke a snackbar's action while it's being closed
3 participants