Skip to content

Conversation

yogeshbhutkar
Copy link
Contributor

@yogeshbhutkar yogeshbhutkar commented Apr 15, 2025

What?

Closes #59139

This PR enhances the Snackbar component by adding support for opening links in a new tab. Accordingly, the View Post, View Site, and View Preview links have been updated to open in a new tab by default.

Why?

Opening these links (View Post, View Site, and View Preview) in a new tab improves the user experience by preserving the current editing context.

How?

Consumers can now pass an openInNewTab boolean property to an action item to open that specific item in a new browser tab.

Testing Instructions

  1. Create a Post.
  2. Write some content and publish it.
  3. After publishing, a snackbar notification will appear.
  4. Click on View Post in the snackbar notification.
  5. Confirm that the link opens in a new tab.

Testing Instructions for Keyboard

Same.

Screencast

PR.mov

@yogeshbhutkar yogeshbhutkar changed the title Snackbar: Add support to open snackbar links in new tab Snackbar: Add support to open links in new tab Apr 15, 2025
@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review April 15, 2025 10:56
Copy link

github-actions bot commented Apr 15, 2025

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: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mtias <matveb@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components labels Apr 15, 2025
@yogeshbhutkar yogeshbhutkar force-pushed the enhance-59139/snackbar-component branch from aa0c974 to 22afc75 Compare April 21, 2025 05:30
@yogeshbhutkar
Copy link
Contributor Author

The failing test appears unrelated to the changes introduced in this PR and passes locally. I believe it should pass upon re-running.

@yogeshbhutkar yogeshbhutkar force-pushed the enhance-59139/snackbar-component branch 2 times, most recently from 8244804 to 6897766 Compare April 25, 2025 11:08
@yogeshbhutkar yogeshbhutkar force-pushed the enhance-59139/snackbar-component branch from 41579bc to 69b10da Compare May 5, 2025 04:03
@yogeshbhutkar
Copy link
Contributor Author

Hi @Mamaduka, if you have some time, I'd really appreciate it if you could review this PR. Thanks in advance!

@Mamaduka Mamaduka self-requested a review May 7, 2025 08:12
@yogeshbhutkar yogeshbhutkar force-pushed the enhance-59139/snackbar-component branch from 69b10da to 1f6bd33 Compare May 8, 2025 10:41
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thank you, @yogeshbhutkar! The changes look good to me ✅

It would be nice to get a sanity check from @WordPress/gutenberg-components team.

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

At a glance, code changes LGTM.

Not allowing onClick ehrn url is defined seems a bit arbitrary, but I guess not in the scope of this PR.

@Mamaduka
Copy link
Member

Mamaduka commented May 9, 2025

Thanks for the feedback, @ciampo!

Let's merge this. We can leave onClick and url behavior as it is for now, changing it might break backward compatibility.

@Mamaduka Mamaduka merged commit 3eea2df into WordPress:trunk May 9, 2025
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.9 milestone May 9, 2025
@yogeshbhutkar yogeshbhutkar deleted the enhance-59139/snackbar-component branch May 15, 2025 13:39
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mtias <matveb@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"View XXX" displayed in the snack bar should open in a new tab
3 participants