Skip to content

Snackbar: Make entire notice clickable when a single action is present#79668

Open
dhruvikpatel18 wants to merge 1 commit into
WordPress:trunkfrom
dhruvikpatel18:feat/clickable-preview-snackbar
Open

Snackbar: Make entire notice clickable when a single action is present#79668
dhruvikpatel18 wants to merge 1 commit into
WordPress:trunkfrom
dhruvikpatel18:feat/clickable-preview-snackbar

Conversation

@dhruvikpatel18

@dhruvikpatel18 dhruvikpatel18 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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

  1. Edit a post.
  2. Click Save Draft.
  3. When the snackbar with "View Preview" appears, click anywhere on the snackbar except directly on the link text/arrow (e.g. the message text, or empty padding).
  4. Confirm the preview opens in a new tab, instead of the snackbar simply dismissing.
  5. Repeat clicking directly on the "View Preview" link/arrow to confirm it still works as before.

Screenshots or screencast

Screen.Recording.2026-06-30.at.3.54.25.PM.mov

@github-actions github-actions Bot added the [Package] Components /packages/components label Jun 30, 2026
@dhruvikpatel18
dhruvikpatel18 marked this pull request as ready for review July 1, 2026 04:36
@dhruvikpatel18
dhruvikpatel18 requested review from a team and ajitbohra as code owners July 1, 2026 04:36
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

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.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Components.

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.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo left a comment

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.

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.

@ciampo
ciampo requested a review from Mamaduka July 1, 2026 07:49
@Mamaduka

Mamaduka commented Jul 1, 2026

Copy link
Copy Markdown
Member

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.

@t-hamano

t-hamano commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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.

I agree with this. Additionally, visual color changes when links within the snackbar are focused or hovered over might be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview snackbar too easily dismissed when intending to click preview link

4 participants