Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert link: the link selection disappears when entering a link #6156

Closed
noisysocks opened this issue Apr 12, 2018 · 18 comments · Fixed by #46212
Closed

Insert link: the link selection disappears when entering a link #6156

noisysocks opened this issue Apr 12, 2018 · 18 comments · Fixed by #46212
Assignees
Labels
[Package] Format library /packages/format-library [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Milestone

Comments

@noisysocks
Copy link
Member

Issue Overview

When inserting a link, your text selection disappears when the focus changes into the Paste URL or type text field. This makes it hard to tell exactly what text you are linking.

Screenshots / Video

new links

Steps to Reproduce (for bugs)

  1. Create a paragraph block
  2. Select some text
  3. Click on the Link button in the formatting toolbar

Expected Behavior

Your cursor should be in the Paste URL or type text field and there should be a blue selection rectangle around the text that you selected.

Current Behavior

Your cursor is in the Paste URL or type text field but the text you selected is no longer selected.

Possible Solution

The classic editor solves this by immediately inserting a link placeholder, as soon as you create a link:

classic links

Related Issues and/or PRs

This was flagged as an issue in #4572 and #5960 (comment). #4909 contained a failed attempt at fixing this.

@noisysocks noisysocks added [Type] Bug An existing feature does not function as intended [Component] TinyMCE [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable labels Apr 12, 2018
@noisysocks noisysocks added this to the Merge Proposal: Editor milestone Apr 12, 2018
@noisysocks noisysocks self-assigned this Jul 11, 2018
@designsimply
Copy link
Member

I tested using WordPress 4.9.7 and Gutenberg 3.3.0 and confirmed that, if I select text and click the link icon in the paragraph block, no formatting or highlighting appears to show me what link text is currently selected. Tested with WordPress 4.9.7 and Gutenberg 3.3.0. (screenshot)

@designsimply designsimply changed the title Link selection disappears when entering a link Insert link: the link selection disappears when entering a link Jul 27, 2018
@talldan
Copy link
Contributor

talldan commented Oct 5, 2018

This seems to have regressed in master - reopening the issue. Unsure why the e2e tests didn't catch it.

@talldan talldan reopened this Oct 5, 2018
@noisysocks
Copy link
Member Author

Is this to do with the recent RichText changes? @WordPress/gutenberg-core

@ellatrix
Copy link
Member

ellatrix commented Oct 5, 2018

Yes, the link UI was rewritten without the placeholder link... We can restore that I guess.

@noisysocks noisysocks removed their assignment Oct 10, 2018
@mtias mtias modified the milestones: Merge: Editor, WordPress 5.0 Oct 12, 2018
@ellatrix ellatrix self-assigned this Oct 31, 2018
@ellatrix
Copy link
Member

I can look into this, but I'm considering it low priority. Feel free remove my assignment if someone else would like to fix.

@gziolo
Copy link
Member

gziolo commented Oct 31, 2018

@talldan or anyone else who has free cyles would you mind helping us with this one? I can tell you that @iseulde is super busy with work these days :)

@ellatrix
Copy link
Member

Tbh I wouldn't add a link placeholder before it's inserted. That seems not so clean, we'd have to make sure the link is removed again etc. Would be nice if we could somehow keep the a selection or render a fake selection or something visible around the target.

@talldan
Copy link
Contributor

talldan commented Nov 2, 2018

Would be nice if we could somehow keep the a selection or render a fake selection or something visible around the target.

@iseulde By fake selection, I'm guessing you mean an element overlayed over the top of the text? I had a look into this idea, and I think it could be a winner. I used a similar approach to positioning the overlay as used in PositionedAtSelection to position the popover. Here's an example of how it looks (it seems to even work for multiple selected lines 🎉, though note the popover isn't particularly well positioned for multiline selections 😢 ):

selection

Need to do some cross-browser testing and tidy up the code, but I'll try to have a PR submitted soon if all goes to plan.

@talldan talldan self-assigned this Nov 2, 2018
@ellatrix
Copy link
Member

ellatrix commented Nov 2, 2018

@talldan Yes, that could be a fine approach. Something else we could try is having an internal format core/selection or something, that doesn't serialise but displays in the editor. So the link format type doesn't have to worry about cleaning it up later. Not sure which would be best though, just thoughts.

@talldan
Copy link
Contributor

talldan commented Nov 2, 2018

Clean up isn't an issue with this approach, as the selection renders in the <InlineLinkUI> component as a sibling of the popover (plus some additional logic to to not render once the link is applied).

@noisysocks
Copy link
Member Author

Remember that different operating systems style text selection differently, and that users can change their text selection colour:

screen shot 2018-11-05 at 11 16 57

The fake selection would have to be styled in a platform agnostic way.

Personally, I think styling the placeholder selection or link as blue underlined text sends the strongest signal that a link is being inserted.

@ellatrix ellatrix closed this as completed Nov 5, 2018
@ellatrix ellatrix reopened this Nov 5, 2018
@noisysocks noisysocks self-assigned this Nov 15, 2018
@mtias mtias added the [Status] In Progress Tracking issues with work in progress label Nov 16, 2018
@youknowriad
Copy link
Contributor

This is more a "nice to have" than a blocking issue.

@noisysocks noisysocks removed the [Status] In Progress Tracking issues with work in progress label Nov 26, 2018
@noisysocks noisysocks removed their assignment Nov 26, 2018
@ellatrix ellatrix added [Package] Format library /packages/format-library and removed [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable labels Jan 29, 2019
@talldan talldan removed their assignment Apr 22, 2020
@paaljoachim
Copy link
Contributor

I am doing a status update.
Using Gutenberg plugin 9.8. Twenty Twenty One. WordPress 5.6.0.

Screen Shot 2021-01-22 at 14 09 24

The issue is still very much valid.

@ellatrix
Copy link
Member

Iframing the content (#21102) will fix this.

@paaljoachim
Copy link
Contributor

Great! As I see the Site Editor iframe PR has been merged then the work on iframing the Post Editor can also continue.

@mtias mtias added [Type] Enhancement A suggestion for improvement. and removed [Type] Bug An existing feature does not function as intended labels May 22, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 30, 2022
@ellatrix ellatrix reopened this Feb 21, 2023
@jordesign
Copy link
Contributor

Iframing task is complete and merged - and this issue is no longer present in my testing - so I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Format library /packages/format-library [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
9 participants