Snackbar: Make entire notice clickable when a single action is present#79668
Snackbar: Make entire notice clickable when a single action is present#79668dhruvikpatel18 wants to merge 1 commit into
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
The solution proposed here feels overengineered and has a few major issues:
- The wrapper click reimplements action behavior instead of delegating to the actual action element;
- The keyboard activation is not limited to the button keys while the wrapper is now labeled as the action.
The original issue also states, as potential approaches:
Either clicking anywhere entire snackbar should open the preview, or some padding should be added to the link to make it an easier click target.
My preference would be to try to make the clickable area of the action larger, either by adding padding, or by adding a pseudo-element that "bleeds" outside the edges of the action. We just need to be careful with the potential overlap with the dismiss button.
|
Clicking on the Snackbar also dismisses it. I personally use this behavior more often than clicking the actions. Making the entire click an intercepted action click introduces a special case, which can be confusing. |
I agree with this. Additionally, visual color changes when links within the snackbar are focused or hovered over might be helpful. |
What?
Closes #71471
Makes the entire Snackbar notice a click target for its action (e.g. "View Preview") when only one action is present, instead of only the action text/link being clickable.
Why?
When a Snackbar has a single action like "View Preview" after saving a post, clicking anywhere on the snackbar that isn't precisely on the link text dismisses the notice instead of triggering the action. This makes it easy to accidentally lose the preview link, especially since the action text is small relative to the rest of the snackbar's clickable surface.
Testing Instructions
Screenshots or screencast
Screen.Recording.2026-06-30.at.3.54.25.PM.mov