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

Split control for URL and Text within Link UI #33849

Merged
merged 63 commits into from
Oct 26, 2021

Conversation

getdave
Copy link
Contributor

@getdave getdave commented Aug 3, 2021

Description

Screen Shot 2021-08-03 at 16 34 55

This PR adds a text field to the Link UI. When editing an existing link are now two separate <input>s within the Link UI provided by the <LinkControl> component for both:

  • link URL
  • link text (new!)

⚠️ Please note

  • the text input is not displayed upon initial link creation. Rather it only appears when you wish to modify an existing link.
  • formatting is not preserved when modifying the link text. This is expected and the rationale for it is explained by @jasmussen in this comment.
  • yes the PR is large but this is mostly tests. I have offered to split it up but folks feel it's probably ok to keep everything in context.

This change effects:

  • Any usages of the core/link format type - that's pretty much all usage of RichText.
  • The Navigation block.

Whilst this UX slightly deviates from the "direct manipulation" paradigm, I believe that in this case it is both necessary and proportionate due to the unique UX considerations around the creation and modification of links.

To quote from the Issue:

When you insert a link block such as a Menu Item or a Button (to a lesser extent, a Social Link), for the block to be functional it needs to have both a URL and a label configured. At the moment, this happens in a single link dialog interface.

If you type arbitrary text, you are meant to be searching for a page or post that you can choose from the dropdown, or create a draft with that title. For example if you type "WordPress", if you just press Enter, you will create a menu item labelled "WordPress" which links to WordPress.

This is based on my original proposal in #19413 which never got anywhere.

Fixes #30170
Closes #22435

How has this been tested?

Manual testing

  • Create a new Post.
  • Add some text.
  • Add a link to a selection of that text - you should only see the URL field when first creating the link. No text field.
  • Click away and then click back on the link you just created. Click Edit in the Link UI.
  • You should see x2 fields:
    • Text
    • URL
  • Try changing the text and submitting (either by click or hitting ENTER). You should see the underlying link text in the paragraph block change to match the contents of the Link UI's text field.
  • Repeat but try:
    • including spaces in your link
    • creating the link at the beginning/end of a piece of text.
    • using the keyboard to select the link

Automated tests

Run the unit tests:

npm run test-unit packages/block-editor/src/components/link-control/

and also:

npm run test-unit packages/format-library/src/link/test

Run the e2e tests:

npm run test-e2e:watch packages/e2e-tests/specs/editor/various/links.test.js

Screenshots

Screen.Capture.on.2021-10-13.at.13-57-22.mov

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.
  • I've tested my changes with keyboard and screen readers.
  • 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 (please manually search all *.native.js files for terms that need renaming or removal).

@getdave getdave added [Block] Navigation Affects the Navigation Block [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels Aug 3, 2021
@getdave getdave self-assigned this Aug 3, 2021
@github-actions
Copy link

github-actions bot commented Aug 3, 2021

Size Change: +880 B (0%)

Total Size: 1.07 MB

Filename Size Change
build/block-editor/index.min.js 135 kB +212 B (0%)
build/block-editor/style-rtl.css 14 kB +126 B (+1%)
build/block-editor/style.css 14 kB +128 B (+1%)
build/block-library/index.min.js 151 kB +59 B (0%)
build/format-library/index.min.js 6.34 kB +355 B (+6%) 🔍
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 931 B
build/admin-manifest/index.min.js 1.09 kB
build/annotations/index.min.js 2.7 kB
build/api-fetch/index.min.js 2.21 kB
build/autop/index.min.js 2.08 kB
build/blob/index.min.js 459 B
build/block-directory/index.min.js 6.2 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 65 B
build/block-library/blocks/archives/style.css 65 B
build/block-library/blocks/audio/editor-rtl.css 58 B
build/block-library/blocks/audio/editor.css 58 B
build/block-library/blocks/audio/style-rtl.css 111 B
build/block-library/blocks/audio/style.css 111 B
build/block-library/blocks/audio/theme-rtl.css 125 B
build/block-library/blocks/audio/theme.css 125 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 470 B
build/block-library/blocks/button/editor.css 470 B
build/block-library/blocks/button/style-rtl.css 549 B
build/block-library/blocks/button/style.css 549 B
build/block-library/blocks/buttons/editor-rtl.css 309 B
build/block-library/blocks/buttons/editor.css 309 B
build/block-library/blocks/buttons/style-rtl.css 317 B
build/block-library/blocks/buttons/style.css 317 B
build/block-library/blocks/calendar/style-rtl.css 207 B
build/block-library/blocks/calendar/style.css 207 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 79 B
build/block-library/blocks/categories/style.css 79 B
build/block-library/blocks/code/style-rtl.css 90 B
build/block-library/blocks/code/style.css 90 B
build/block-library/blocks/code/theme-rtl.css 131 B
build/block-library/blocks/code/theme.css 131 B
build/block-library/blocks/columns/editor-rtl.css 206 B
build/block-library/blocks/columns/editor.css 205 B
build/block-library/blocks/columns/style-rtl.css 497 B
build/block-library/blocks/columns/style.css 496 B
build/block-library/blocks/cover/editor-rtl.css 546 B
build/block-library/blocks/cover/editor.css 547 B
build/block-library/blocks/cover/style-rtl.css 1.17 kB
build/block-library/blocks/cover/style.css 1.17 kB
build/block-library/blocks/embed/editor-rtl.css 488 B
build/block-library/blocks/embed/editor.css 488 B
build/block-library/blocks/embed/style-rtl.css 417 B
build/block-library/blocks/embed/style.css 417 B
build/block-library/blocks/embed/theme-rtl.css 124 B
build/block-library/blocks/embed/theme.css 124 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 255 B
build/block-library/blocks/file/style.css 255 B
build/block-library/blocks/file/view.min.js 322 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 977 B
build/block-library/blocks/gallery/editor.css 982 B
build/block-library/blocks/gallery/style-rtl.css 1.6 kB
build/block-library/blocks/gallery/style.css 1.59 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 159 B
build/block-library/blocks/group/editor.css 159 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 114 B
build/block-library/blocks/heading/style.css 114 B
build/block-library/blocks/home-link/style-rtl.css 247 B
build/block-library/blocks/home-link/style.css 247 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 731 B
build/block-library/blocks/image/editor.css 730 B
build/block-library/blocks/image/style-rtl.css 502 B
build/block-library/blocks/image/style.css 505 B
build/block-library/blocks/image/theme-rtl.css 124 B
build/block-library/blocks/image/theme.css 124 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B
build/block-library/blocks/latest-posts/editor.css 137 B
build/block-library/blocks/latest-posts/style-rtl.css 528 B
build/block-library/blocks/latest-posts/style.css 527 B
build/block-library/blocks/list/style-rtl.css 94 B
build/block-library/blocks/list/style.css 94 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 493 B
build/block-library/blocks/media-text/style.css 490 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 488 B
build/block-library/blocks/navigation-link/editor.css 489 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B
build/block-library/blocks/navigation-link/style.css 94 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation-submenu/style-rtl.css 195 B
build/block-library/blocks/navigation-submenu/style.css 195 B
build/block-library/blocks/navigation-submenu/view.min.js 343 B
build/block-library/blocks/navigation/editor-rtl.css 1.78 kB
build/block-library/blocks/navigation/editor.css 1.78 kB
build/block-library/blocks/navigation/style-rtl.css 1.71 kB
build/block-library/blocks/navigation/style.css 1.7 kB
build/block-library/blocks/navigation/view.min.js 2.74 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 377 B
build/block-library/blocks/page-list/editor.css 377 B
build/block-library/blocks/page-list/style-rtl.css 198 B
build/block-library/blocks/page-list/style.css 198 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/paragraph/style-rtl.css 273 B
build/block-library/blocks/paragraph/style.css 273 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/style-rtl.css 347 B
build/block-library/blocks/post-comments-form/style.css 347 B
build/block-library/blocks/post-comments/style-rtl.css 475 B
build/block-library/blocks/post-comments/style.css 475 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 396 B
build/block-library/blocks/post-featured-image/editor.css 397 B
build/block-library/blocks/post-featured-image/style-rtl.css 156 B
build/block-library/blocks/post-featured-image/style.css 156 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 391 B
build/block-library/blocks/post-template/style.css 392 B
build/block-library/blocks/post-terms/style-rtl.css 73 B
build/block-library/blocks/post-terms/style.css 73 B
build/block-library/blocks/post-title/style-rtl.css 60 B
build/block-library/blocks/post-title/style.css 60 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 198 B
build/block-library/blocks/pullquote/editor.css 198 B
build/block-library/blocks/pullquote/style-rtl.css 378 B
build/block-library/blocks/pullquote/style.css 378 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 262 B
build/block-library/blocks/query-pagination/editor.css 255 B
build/block-library/blocks/query-pagination/style-rtl.css 234 B
build/block-library/blocks/query-pagination/style.css 231 B
build/block-library/blocks/query/editor-rtl.css 131 B
build/block-library/blocks/query/editor.css 132 B
build/block-library/blocks/quote/style-rtl.css 187 B
build/block-library/blocks/quote/style.css 187 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 397 B
build/block-library/blocks/search/style.css 398 B
build/block-library/blocks/search/theme-rtl.css 64 B
build/block-library/blocks/search/theme.css 64 B
build/block-library/blocks/separator/editor-rtl.css 99 B
build/block-library/blocks/separator/editor.css 99 B
build/block-library/blocks/separator/style-rtl.css 250 B
build/block-library/blocks/separator/style.css 250 B
build/block-library/blocks/separator/theme-rtl.css 172 B
build/block-library/blocks/separator/theme.css 172 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 770 B
build/block-library/blocks/site-logo/editor.css 770 B
build/block-library/blocks/site-logo/style-rtl.css 165 B
build/block-library/blocks/site-logo/style.css 165 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 84 B
build/block-library/blocks/site-title/editor.css 84 B
build/block-library/blocks/social-link/editor-rtl.css 177 B
build/block-library/blocks/social-link/editor.css 177 B
build/block-library/blocks/social-links/editor-rtl.css 824 B
build/block-library/blocks/social-links/editor.css 823 B
build/block-library/blocks/social-links/style-rtl.css 1.32 kB
build/block-library/blocks/social-links/style.css 1.32 kB
build/block-library/blocks/spacer/editor-rtl.css 307 B
build/block-library/blocks/spacer/editor.css 307 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 471 B
build/block-library/blocks/table/editor.css 472 B
build/block-library/blocks/table/style-rtl.css 481 B
build/block-library/blocks/table/style.css 481 B
build/block-library/blocks/table/theme-rtl.css 188 B
build/block-library/blocks/table/theme.css 188 B
build/block-library/blocks/tag-cloud/style-rtl.css 146 B
build/block-library/blocks/tag-cloud/style.css 146 B
build/block-library/blocks/template-part/editor-rtl.css 560 B
build/block-library/blocks/template-part/editor.css 559 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 571 B
build/block-library/blocks/video/editor.css 572 B
build/block-library/blocks/video/style-rtl.css 173 B
build/block-library/blocks/video/style.css 173 B
build/block-library/blocks/video/theme-rtl.css 124 B
build/block-library/blocks/video/theme.css 124 B
build/block-library/common-rtl.css 815 B
build/block-library/common.css 812 B
build/block-library/editor-rtl.css 9.67 kB
build/block-library/editor.css 9.67 kB
build/block-library/reset-rtl.css 474 B
build/block-library/reset.css 474 B
build/block-library/style-rtl.css 10.5 kB
build/block-library/style.css 10.5 kB
build/block-library/theme-rtl.css 668 B
build/block-library/theme.css 673 B
build/block-serialization-default-parser/index.min.js 1.09 kB
build/block-serialization-spec-parser/index.min.js 2.79 kB
build/blocks/index.min.js 46 kB
build/components/index.min.js 212 kB
build/components/style-rtl.css 15.4 kB
build/components/style.css 15.4 kB
build/compose/index.min.js 10.4 kB
build/core-data/index.min.js 12.4 kB
build/customize-widgets/index.min.js 11.2 kB
build/customize-widgets/style-rtl.css 1.5 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 614 B
build/data/index.min.js 7.1 kB
build/date/index.min.js 31.5 kB
build/deprecated/index.min.js 428 B
build/dom-ready/index.min.js 304 B
build/dom/index.min.js 4.44 kB
build/edit-navigation/index.min.js 15.8 kB
build/edit-navigation/style-rtl.css 3.76 kB
build/edit-navigation/style.css 3.76 kB
build/edit-post/classic-rtl.css 492 B
build/edit-post/classic.css 494 B
build/edit-post/index.min.js 29.4 kB
build/edit-post/style-rtl.css 7.12 kB
build/edit-post/style.css 7.12 kB
build/edit-site/index.min.js 30.7 kB
build/edit-site/style-rtl.css 5.78 kB
build/edit-site/style.css 5.78 kB
build/edit-widgets/index.min.js 16.3 kB
build/edit-widgets/style-rtl.css 4.17 kB
build/edit-widgets/style.css 4.18 kB
build/editor/index.min.js 37.7 kB
build/editor/style-rtl.css 3.78 kB
build/editor/style.css 3.77 kB
build/element/index.min.js 3.21 kB
build/escape-html/index.min.js 517 B
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 424 B
build/i18n/index.min.js 3.6 kB
build/is-shallow-equal/index.min.js 501 B
build/keyboard-shortcuts/index.min.js 1.72 kB
build/keycodes/index.min.js 1.3 kB
build/list-reusable-blocks/index.min.js 1.85 kB
build/list-reusable-blocks/style-rtl.css 838 B
build/list-reusable-blocks/style.css 838 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 845 B
build/nux/index.min.js 2.03 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.83 kB
build/primitives/index.min.js 921 B
build/priority-queue/index.min.js 582 B
build/react-i18n/index.min.js 671 B
build/redux-routine/index.min.js 2.63 kB
build/reusable-blocks/index.min.js 2.19 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.7 kB
build/server-side-render/index.min.js 1.52 kB
build/shortcode/index.min.js 1.48 kB
build/token-list/index.min.js 562 B
build/url/index.min.js 1.74 kB
build/viewport/index.min.js 1.02 kB
build/warning/index.min.js 248 B
build/widgets/index.min.js 7.11 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.04 kB

compressed-size-action

@getdave
Copy link
Contributor Author

getdave commented Aug 3, 2021

Ok @jasmussen here is a PoC for the dual controls for text and URL.

Considerations:

  1. I saw the original (now pretty old) design has completely different UI for searching/selecting entities (eg: pages, posts...etc). IMHO that's a wider issue which would probably be best tackled separately from this PR as it would be a very large job.
  2. I've decided to implement this using the existing LinkControl component. For backwards compatibility the addition of the hasTextControl property decides whether or not to show the new text control. For now I've only enabled on the Nav Link block so we need to test backwards compatibility.
  3. We probably need to reconsider the style/position of the submit button. Do we leave "as is" within the URL input (as that is the primary input) or do we move it outside and make it more obvious?
  4. We'll need to update the focus handling logic to put the cursor focus inside the URL input when first triggering the Link UI. Currently it focuses the link text which is probably weird, especially if you are searching.
  5. Do we need to give additional visual affordance to the link URL to make it obvious this powers the "search" aspect? Currently it's a little confusing as to which input I should "search" within. Check out how Google docs does this with a search icon within the URL input.
  6. Should we ultimately look to implement the same dual control on all instances of the Link UI within the editor. I'd say there's probably value there.

There's probably more I forgot...

@jasmussen
Copy link
Contributor

jasmussen commented Aug 4, 2021

Thanks for working on this. This is what I see:

hey

A couple of responses:

I saw the original (now pretty old) design has completely different UI for searching/selecting entities (eg: pages, posts...etc). IMHO that's a wider issue which would probably be best tackled separately from this PR as it would be a very large job.
We probably need to reconsider the style/position of the submit button. Do we leave "as is" within the URL input (as that is the primary input) or do we move it outside and make it more obvious?

The designs at least for the dropdowns themselves are still mostly up to date, but yes most of the unique per-block-type behavior is probably fine to explore and separately, but start with the simplest.

At the same time, one thing that becomes clear in testing this is that the link suggestions are very prominent here. Which in part makes sense since they all skew heavily towards pages and existing content on the site. But at the same time, one of the benefits of the tailored destination picker is that it can be smarter in the suggestions. So in that way, the placement of the submit button is likely dependant on some tweaks to the suggestions list itself. I'd be happy to jump in with tweaks directly in this branch when I have a moment (possibly next week).

We'll need to update the focus handling logic to put the cursor focus inside the URL input when first triggering the Link UI. Currently it focuses the link text which is probably weird, especially if you are searching.

Not sure. In a later mockup made for a different ticket (#32373), the title is a key part of the flow being first:

Setup states   appenders

Do we need to give additional visual affordance to the link URL to make it obvious this powers the "search" aspect? Currently it's a little confusing as to which input I should "search" within. Check out how Google docs does this with a search icon within the URL input.

Yes, this is perhaps the most important discovery of your PR here (thank you!). As shown in the mockup above, an initial instinct with these designs was for the suggestions to be an even more light-weight search-suggestions dropdown that appeared as you started typing, rather than right off the bat.

At the same time, the value of those suggestions intrinsically becomes reduce when hidden until you start typing. So I might need to noodle on this a bit more.

Should we ultimately look to implement the same dual control on all instances of the Link UI within the editor. I'd say there's probably value there.

I think so too! I think we might know better, depending on where this PR goes.


From testing the PR here, the split dialog allows you to fill out the text label before you select a destination. Right now that's not saved in this PR, and in order to fix that it seems like we might have to also address #33091 while we're at it.

As also noted above, the biggest mindbender to think about is how to integrate the search suggestions in a way that keeps their suggestive value, but still work within the reduced design and smaller dialog that includes the label. Perhaps it's fine to just simplify those suggestions (a la Google Docs as you suggest), but it needs some design tinkering which I'll return with.

Nice work!

@jasmussen jasmussen mentioned this pull request Aug 4, 2021
7 tasks
@getdave
Copy link
Contributor Author

getdave commented Aug 4, 2021

Appreciate your review and thoughts @jasmussen 👍

At the same time, one thing that becomes clear in testing this is that the link suggestions are very prominent here...I'd be happy to jump in with tweaks directly in this branch when I have a moment (possibly next week).

I agree that the suggestions list needs some design attention. Mainly we need to make it clearer these are results associated with the search input. Also we need to consider that any design tweaks needs to be backwards compatible with the Link UI when the text control is not enabled (if we're going to make this opt in...).

Not sure. In a later mockup made for a different ticket (#32373), the title is a key part of the flow being first:

Re: auto-focusing the URL input as opposed to the text input.

I'd like to clarify the expectations around the link text. For example, do we consider a link valid (and thus submittable) if there is no URL? How does that work in the Nav Block vs in Rich Text?

Also note that currently you have to click "Submit" for the text to be retained. I think that's correct.

...an initial instinct with these designs was for the suggestions to be an even more light-weight search-suggestions dropdown that appeared as you started typing, rather than right off the bat. At the same time, the value of those suggestions intrinsically becomes reduce when hidden until you start typing. So I might need to noodle on this a bit more.

Personally I don't like the suggestions showing right off that bat. It's distracting and additional visual noise. I think we added it as a nice way to show "most recent", but I think it's easy to turn that off via a prop if we wish to do so.

Something else to consider is that users have specifically indicated use cases whereby having lots of detail in the search suggestions is very helpful/important. We should be mindful of this before streamlining these suggestions too much.

From testing the PR here, the split dialog allows you to fill out the text label before you select a destination. Right now that's not saved in this PR, and in order to fix that it seems like we might have to also address #33091 while we're at it.

Initially I disabled the text input until the user had selected a URL. However that meant you couldn't adjust the text until after which I didn't think was the best UX. However note that the text is not "saved" until you click submit which you can't do until you've also selected a URL. If we can clarify the expected flow here I can adjust the code to suit.

Nice work!

Thank you 🙇 .

@jasmussen
Copy link
Contributor

I'd like to clarify the expectations around the link text. For example, do we consider a link valid (and thus submittable) if there is no URL? How does that work in the Nav Block vs in Rich Text?

The genesis of #33091 was to allow designers to create patterns that had navigation menus with preset labels, but whose links were empty. The idea being that you could create highly opinionated navigation patterns that suggested not only a specific amount of menu items, but specific labels as well. All the while still keeping those menu items in "draft states", i.e. having the wavy underline until both link and label were filled out, and not showing on the frontend until that was the case.

If we were to unify so both text and URL are shown also for hyperlinked rich text, you're asking: what would happen if you then edited a link to not have a label? I think we could do two things:

  • Ignore that
  • Replace convert the selection to the link itself (this is what Google Docs does)

Personally I don't like the suggestions showing right off that bat. It's distracting and additional visual noise. I think we added it as a nice way to show "most recent", but I think it's easy to turn that off via a prop if we wish to do so.

I agree, but I'd like to explore a few directions just to be sure we're improving.

Something else to consider is that users have specifically indicated use cases whereby having lots of detail in the search suggestions is very helpful/important. We should be mindful of this before streamlining these suggestions too much.

Absolutely. I think we can do things with compression, font size, font appearance, color, margins, paddings, and if we go deeper, even better contextuality. I always get the same 3 page suggestions when I've made no search yet, (though perhaps that's an argument to make it on-type contextual).

@getdave
Copy link
Contributor Author

getdave commented Aug 5, 2021

  • Replace convert the selection to the link itself (this is what Google Docs does)

That's what we do in this PR already. If you add a link without text (or delete existing text) and click submit you will see it uses the hyperlink as the title unless there is a title provided by the suggestion you clicked.

I agree, but I'd like to explore a few directions just to be sure we're improving.

Looking forward to seeing next steps for me to implement in terms of UI, specifically around suggestions 👍

@getdave getdave marked this pull request as ready for review August 5, 2021 13:40
@getdave getdave removed the request for review from ellatrix August 5, 2021 13:40
@jasmussen
Copy link
Contributor

Looking forward to seeing next steps for me to implement in terms of UI, specifically around suggestions 👍

I haven't forgotten this one! I'll return as soon as I get space to expand this! Thanks for your patience.

@getdave
Copy link
Contributor Author

getdave commented Aug 6, 2021

Looking forward to seeing next steps for me to implement in terms of UI, specifically around suggestions 👍

I haven't forgotten this one! I'll return as soon as I get space to expand this! Thanks for your patience.

Im AFK until next week now so no worries 🙂

@jasmussen
Copy link
Contributor

I did some design work in #30170 (comment), which I think I need to sleep on, or at least step away for lunch and then come back to.

@jasmussen
Copy link
Contributor

Just as a small update, this is still on my radar, but #34041 has come around and become a priority. The good news is there is likely some overlap between the efforts here and the efforts there. I'll be sure to update here when I have more.

@jasmussen
Copy link
Contributor

I have some new mockups in #30170 (comment) that I would love your thoughts on at your convenience. Thank you.

@getdave
Copy link
Contributor Author

getdave commented Sep 15, 2021

I have some new mockups in #30170 (comment) that I would love your thoughts on at your convenience. Thank you.

Responded #30170 (comment)

@gwwar
Copy link
Contributor

gwwar commented Sep 22, 2021

Nice, there was already some work on this one. I'll try to catch up on this one, I was playing around with patterns and using label text as a placeholder in #35063.

@getdave
Copy link
Contributor Author

getdave commented Sep 24, 2021

Nice, there was already some work on this one.

Yeh it's this PR 😆

I'm working on it right now. Would love more 👀

@getdave getdave force-pushed the try/link-control-split-url-text branch from 7fca70e to 1e94414 Compare October 26, 2021 16:45
@noisysocks noisysocks merged commit d00ec9a into trunk Oct 26, 2021
@noisysocks noisysocks deleted the try/link-control-split-url-text branch October 26, 2021 23:56
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Oct 26, 2021
@getdave getdave mentioned this pull request Oct 27, 2021
38 tasks
@gwwar
Copy link
Contributor

gwwar commented Oct 27, 2021

🎉 nice to see that this one landed. Great work @getdave !

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 [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting)
Projects
None yet
7 participants