[@wordpress/notices] Add a new action removeNotices which allows bulk removal of notices#39940
Merged
nerrad merged 9 commits intoWordPress:trunkfrom May 30, 2023
Merged
[@wordpress/notices] Add a new action removeNotices which allows bulk removal of notices#39940nerrad merged 9 commits intoWordPress:trunkfrom
@wordpress/notices] Add a new action removeNotices which allows bulk removal of notices#39940nerrad merged 9 commits intoWordPress:trunkfrom
Conversation
4 tasks
08082b4 to
927fb58
Compare
Contributor
|
Thank you for putting this together! Would you be able to add an example to the docblock? It does a long way in helping developers wanting to use this action. Here is an example for reference |
nerrad
approved these changes
Sep 11, 2022
Contributor
nerrad
left a comment
There was a problem hiding this comment.
Looks good, test well. E2E tests seem to be unrelated.
Contributor
Author
|
@ryanwelcher great idea, thanks. I've updated the PR to include an example. |
Contributor
Author
|
@nerrad this has been rebased and tested. On my end it works OK. |
Contributor
|
|
sethrubenstein
pushed a commit
to pewresearch/gutenberg
that referenced
this pull request
Jul 13, 2023
…bulk removal of notices (WordPress#39940) * Add removeNotices action creator * Handle REMOVE_NOTICES in reducer * Add tests for reducer and actions * Move test to better position and add one for multiple contexts * Use .filter instead of reject * Add example component to doc block * Add changelog entry * Correct spacing on list item * Add correct changelog heading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Adds a new action on the
core/noticesstore that will remove several notices at once by supplying multiple IDs.removeNotices( [ 'some-id', 'some-other-id' ] )Why?
To remove multiple notices, you'd need to make several calls to
removeNoticethis makes a slight performance improvement by only dispatching one action.An example use case is in WooCommerce Blocks where we need to remove several notices of a certain type.
Currently we loop through each notice and dispatch the
removeNoticeaction for each of them. It would be more performant if we could dispatch a single action and achieve the same result.How?
Adds a new action creator and the action is handled in a new case in the reducer.
Testing Instructions
Test 2error.