Gutenberg: Make linking only work when you have selected text

Created on 3 Apr 2018  路  6Comments  路  Source: WordPress/gutenberg

Right now you can add a link on no text. This is an existing limitation in WordPress, the blocks makes this even more of an issue as more and more won't be interacting or correcting this via code.

2018-04-03 at 21 19

Whilst I understand this may be an issue with Tiny MCE, what about taking this a little further and only showing the link icon if you have selected text?

2018-04-03 at 21 12

Needs Dev [Type] Enhancement

Most helpful comment

Could we insert the link with the URL set as the link's text? This would align with what a lot of text editors do, e.g. TextEdit:

links

All 6 comments

Perhaps instead of only showing the link icon when text is selected, make it clickable only when text is selected. That way people know they have the ability to add a link, but can't accidentally add a link to a section of no text. Getting rid of it when nothing is selected could be confusing.

@twsp I am ok with greying it out if there is enough contrast. I don't absolutely think it would be confusing to show contextual actions, we do that in a lot of places. I'm up for either option, the action of not having it working is the experience I'm focused on.

Could we insert the link with the URL set as the link's text? This would align with what a lot of text editors do, e.g. TextEdit:

links

Hmmm great idea! Let's have that as the option, it makes a lot of sense over the nothing entry. Thanks for the suggestion!

Perhaps in addition to this, there's an issue where the selection disappears when you enter the link modal:

new links

This is likely due to focus having to be there, and when you set focus elsewhere, the previous selection is unset. Maybe.

In any case, it looks like the classic editor solves this by immediately inserting a link placeholder, as soon as you create a link:

classic links

Bundle a fix for that one into this? :) 馃崚

@jasmussen: Yeah, that's something that was originally a part of https://github.com/WordPress/gutenberg/issues/4572. I ran into a lot of pain (see https://github.com/WordPress/gutenberg/pull/4909#issuecomment-364360350) while implementing it though and so I gave up... for now. I'll create a seperate issue so that we remember to address this before merge 馃檪

Was this page helpful?
0 / 5 - 0 ratings