gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Button block - option to 'Open in new window'

Open danztoxsmith opened this issue 8 years ago • 41 comments

Please can we have the option to 'open in a new window' on the button block? Either in the inspector controls or done in the same way as links (image below).

image

This was mentioned in #1404 with the button label but it seems the part about setting the target was missed.

danztoxsmith avatar Jul 17 '18 14:07 danztoxsmith

Adding a screenshot showing the current state of the button block floating toolbar:

screen shot 2018-07-17 at tue jul 17 11 14 54 am Seen at http://alittletestblog.com/wp-admin/post.php?post=14000&action=edit running WordPress 4.9.7 and Gutenberg 3.2.0 using Firefox 61.0.1 on macOS 10.13.5.

designsimply avatar Jul 17 '18 17:07 designsimply

Worth noting this has been mentioned also in https://github.com/WordPress/gutenberg/issues/3350#issuecomment-410531124 with some more details. The point is while other blocks (Paragraph, Image, etc.) use a standardised URLInput component, instead the Button component uses a custom implementation of the URL input field and it misses the option "open in a new window". Also, the design is different:

afercia avatar Sep 21 '18 15:09 afercia

@afercia Great point. It may be better to change the Button component to use the standardized URLInput component. However, I'm not sure if it was implemented this way on purpose.

therajumandapati avatar Sep 21 '18 16:09 therajumandapati

@chrisvanpatten @aduth @youknowriad (sorry, not sure who's more appropriate to be involved on this issue) Maybe we don't need to use RichText in the Button component at all? It's not a general use-case to have parts of a button bold or italic. Either the entire button is bold or italic or not.

therajumandapati avatar Sep 21 '18 17:09 therajumandapati

Submitted #10128 which addresses this enhancement.

nfmohit avatar Sep 23 '18 16:09 nfmohit

Will this feature be implemented at the core? if so, when?

shoxton avatar Jan 18 '19 22:01 shoxton

There's another PR #12738 addressing this issue, would be great to see one of them merged soon.

therajumandapati avatar Jan 29 '19 18:01 therajumandapati

@shoxton it looks like work on this has been picked up by @nfmohit-wpmudev at https://github.com/WordPress/gutenberg/pull/10128 and that there is also recent discussion on that pull request, however, there is no guarantee of a timeline for something like that to get added and generally it depends on how much time the core team and other committers and contributors have to work on pull requests as well as code reviews for each other. In this case, it looks like there's some recent movement which is great!

@mvpspl619 thank you so much for the note about 12738!

designsimply avatar Jan 29 '19 19:01 designsimply

Would be amazing, buttons are an important part of a UI, and not being able to direct to an external link in a new tab (as well as nofollow, noopener etc...) is quite a limiting parameter.

BrunoBoehm avatar Feb 25 '19 14:02 BrunoBoehm

It is essential to have (open in new tab) option just like other components for Buttons as well. +1 vote to have that option in next release. Thanks

eddieali avatar Feb 26 '19 15:02 eddieali

+1 from a WordPress.com customer

kristarella avatar Mar 21 '19 00:03 kristarella

Being able to choose to open a button link in a new window? Yes + 1 on that.

morgangrip avatar Mar 27 '19 09:03 morgangrip

+1 to this as well. The buttons are great, just that it'll be much better if we could have an option to open it in a new tab.

Btw, am quite inexperienced with this so hope you guys don't mind me asking again if it was already asked above or in other threads. May I know what is the quick fix/alternative to make the block open in a new tab? Editing the html? Many thanks!

mattpan32 avatar Mar 28 '19 03:03 mattpan32

Another frustrated Gutenberg user that battles with buttons that do not offer a target setting.... Get it together

edwinhamers avatar Apr 01 '19 11:04 edwinhamers

+1 to this as well. The buttons are great, just that it'll be much better if we could have an option to open it in a new tab.

Btw, am quite inexperienced with this so hope you guys don't mind me asking again if it was already asked above or in other threads. May I know what is the quick fix/alternative to make the block open in a new tab? Editing the html? Many thanks!

@mattpan32 you can try adding the target="_blank" attribute to the button element, or just use the link block that has the "open in new tab" functionality.

shoxton avatar Apr 01 '19 12:04 shoxton

+1 to this as well. The buttons are great, just that it'll be much better if we could have an option to open it in a new tab. Btw, am quite inexperienced with this so hope you guys don't mind me asking again if it was already asked above or in other threads. May I know what is the quick fix/alternative to make the block open in a new tab? Editing the html? Many thanks!

@mattpan32 you can try adding the target="_blank" attribute to the button element, or just use the link block that has the "open in new tab" functionality.

Isnt Gutenberg supposed to "streamline the editing".

edwinhamers avatar Apr 01 '19 12:04 edwinhamers

@mattpan32 you can try adding the target="_blank" attribute to the button element, or just use the link block that has the "open in new tab" functionality. Adding it to the button block results in an "unexpected or invalid content" error and you have to convert to html. The only way that seems to work right now is just creating a link in a paragraph, editing the html for that block, and adding class="wp-block-button__link" to the link there.

ohlauren avatar Apr 15 '19 18:04 ohlauren

+1 from a WordPress.com user in #12136336-hc (noting for myself as they asked me to notify them if this ever does end up being implemented)

lakellie avatar Apr 22 '19 16:04 lakellie

+1

fosterTerence avatar Apr 27 '19 06:04 fosterTerence

+1 also but, until this is added, here is how to achieve this:

Here is a button as normal, without the '_blank' new page option:

Button_1

Under the button options, select 'Edit as HTML':

Button_2

Now edit the HTML to add the code target="_blank" as shown, and save:

Button_3

Clicking the button will now open in new page.

rendzina avatar May 02 '19 09:05 rendzina