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

Make Nav Link Block text also editable from within the hyperlinklink creation UI #19413

Closed

Conversation

getdave
Copy link
Contributor

@getdave getdave commented Jan 6, 2020

linkuiwithtext

Experimental.

In the current Navigation Block, it could be argued that there is something of a disconnect between adding link text and creating the hyperlink destination of the link. when creating a Nav Link.

To add a hyperlink you interact with a LinkControl popover. This affords the ability to add a URL by direct entry or searching for an existing Post. However it does not enable editing of the link text itself.

To edit link text you need to switch away from the LInKControl popover and edit within the Block richtext directly. Whilst it is obviously desirable to retain the direct manipulation pattern established on blocks, it can feel a little clunky (and somewhat confusing) to have to switch between hyperlink UI and the block itself in order to create a link.

This PR is an experiment to see whether introducing the ability to edit the Nav Item text from within the hyperlink UI as well as the block richtext would improve the usability.

This follows established UI patterns such as that found in Google Docs (see screenshot below) which enables manipulation of the link text within the hyperlink UI:

Screenshot 2020-01-06 at 10 18 57

I'm expecting that this will be rejected on the grounds of breaking the direct manipulation paradigm, but I felt it was worth exploring so we can at least rule it out and have documented evidence of this process having occurred.

Please note there is a currently a major bug in this implementation whereby editing the text within the hyperlink UI will cause focus to immediately jump back to the block richtext. This is likely due to a "bug" in RichText which would need to be fixed in order for this to work (cc @ellatrix ). Therefore please suspend disbelief when testing this PR or just take the screenshot at face value.

How has this been tested?

Manual for now.

Screenshots

72170288-84a36d00-33c8-11ea-99a5-2eda07b53133

Types of changes

New feature (non-breaking change which adds functionality).

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@getdave getdave added [Status] In Progress Tracking issues with work in progress [Block] Navigation Affects the Navigation Block [Package] Block editor /packages/block-editor labels Jan 6, 2020
@getdave getdave self-assigned this Jan 6, 2020
@getdave getdave changed the base branch from master to refactor/link-control-api January 6, 2020 10:25
@WunderBart
Copy link
Member

This follows established UI patterns such as that found in Google Docs

I think it's a good pattern in a scenario when a user doesn't have the ability to freely edit the text directly from the editor. Like in Google Docs - once you delete the first or the last character of the created link, you won't be able to add it back unless starting from the middle of the text or using the popover:

link popover google docs

In our current (production) implementation, we seem to have that ability (arrow-left after backspace):

link popover gutenberg

I still think it can nicely improve the editing experience though. For ex. tab-rotating between the text->URL->submit while the popover is open (like in the Google Docs one) has a good feel for me. I like the fact there that the popover doesn't get out of focus accidentally, so I can close it when I'm done editing.

@getdave
Copy link
Contributor Author

getdave commented Jan 10, 2020

When applying @ellatrix's fix to RichText focus, we get the following:

Screen Capture on 2020-01-10 at 16-43-43

Once this lands we can rebase this PR.

@getdave
Copy link
Contributor Author

getdave commented Jan 10, 2020

@mtias This is purely an experiment I did in my free time, but I'm keen to see what you think because I have a feeling you won't be in favour of this approach and I don't want to spend further time on it if you feel it's not the right direction.

I know the direct manipulation paradigm is very important but please do note my comments in the PR description as to why I felt it was worth exploring.

Very much appreciated.

@getdave
Copy link
Contributor Author

getdave commented Feb 23, 2020

With latest improvements in Nav I no longer feel this is required.

@getdave getdave closed this Feb 23, 2020
@youknowriad youknowriad deleted the try/nav-item-text-inside-link-ui branch February 24, 2020 08:22
@getdave
Copy link
Contributor Author

getdave commented Apr 24, 2020

I'm happy to pick this up again if anyone feels it would be useful. Please ping me.

@dwolfe
Copy link

dwolfe commented Apr 24, 2020

🖐️ I think it would be useful!

To elaborate, I think this is specifically a problem when adding a link, not necessarily editing. When you add a link, you click the inserter button, and focus immediately goes to the URL field. The placeholder/hint for the link text is greyed out, which is what it's supposed to look like, ie. that's a good thing, but I think there's a slight mental jump to direct your attention back up to where you clicked, and realize that that's where you enter the link text.

I don't think editing has the same problem, because you click the link text itself to select the menu item, and the I-bar lets you know that you can edit that text. But for adding a link, I think the explicit field is more clear. Worth noting that Google Docs only has the additional field when you first add a link, as well.

Here's a quick GIF (there are a few other design tweaks here - you can ignore those, I'm merely trying to illustrate the addition of the "Link text" field):

A-Few-Tweaks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Package] Block editor /packages/block-editor [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants