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

WP components audit: ExternalLink & Link #16542

Closed
davewhitley opened this issue Jul 11, 2019 · 4 comments
Closed

WP components audit: ExternalLink & Link #16542

davewhitley opened this issue Jul 11, 2019 · 4 comments
Labels
[Feature] UI Components Impacts or related to the UI component system Needs Design Feedback Needs general design feedback. Needs Technical Feedback Needs testing from a developer perspective. [Package] Components /packages/components

Comments

@davewhitley
Copy link
Contributor

davewhitley commented Jul 11, 2019

Is your feature request related to a problem? Please describe.

This issue is part of a review on the naming, structure, and composition of the UI components as brought up in #16367

Link vs Button

Please see this comment on how the link vs button discussion relates to this component library audit: #7534 (comment)

ExternalLink

Screen Shot 2019-07-09 at 10 41 38 PM

Audit

Opportunities I came across while reviewing this component.

  • Based on the name, I expected there to be also a Link component.

Grouping

  • I expect this component to live in a Buttons category or as a top level item.

Suggestions

  • I suggest we create a Link component with 'external' as a prop.

Link (new)

This component doesn't exist but I believe there is a strong need for one, and it is relevant to the naming and structure of existing Button and ExternalLink elements.

Usage examples of Link

Links are standard in several component libraries. Here is a summary of what they can be used for:

Links are used primarily as a navigational element. Links may also change what or how data is displayed (i.e., view more, show all). If the action taken by the user will change or manipulate data, use a button. (Carbon)

Links are used to embed actions or pathways to more information in a sentence. (Polaris)

The Link component creates a hyperlink to external pages, files, anchors on the same page, or another URL. (Mineral UI)

Feedback

The feedback I'm looking for is related to naming, structure, and composition. I'm not looking for visual feedback of the components.Prop audit can be seen in the comment below.

@davewhitley
Copy link
Contributor Author

davewhitley commented Jul 19, 2019

Props audit

As an addendum, here is a deeper evaluation of the props for these components. This is an effort to expand the components to be more useful and to answer the question, "Are properties well thought out and consistently applied?" This only covers visual props. Event handler props will be evaluated at a later date.

Link

✨ New

  • external: provides external icon and tooltip that informs the user about leaving the page.
  • danger: red colored link.
  • monochrome: uses inherit color, if you'd like the link to be the same color as surrounding text.

Event handler props will be evaluated at a later date.

@davewhitley davewhitley added Needs Design Feedback Needs general design feedback. Needs Technical Feedback Needs testing from a developer perspective. Needs Accessibility Feedback Need input from accessibility labels Jul 19, 2019
@enriquesanchez
Copy link
Contributor

external: provides external icon and tooltip that informs the user about leaving the page.

👍 👍

Also, any chance we can add to the docs a summary of the WCAG's recommendations on external links?

In summary, it's recommended to avoid external links because some users can get confused with the new windows or tabs, so they should be used with caution.

@enriquesanchez enriquesanchez removed the Needs Accessibility Feedback Need input from accessibility label Aug 7, 2019
@afercia
Copy link
Contributor

afercia commented Aug 22, 2019

I suggest we create a Link component with 'external' as a prop.

Worth noting 'external' doesn't necessarily mean a link must open in a new browser's tab (by using target="_blank". Links to external sites can open in the same tab. Conversely, links to the same site may open in a new tab. Both usages are present in core, although the visual look of the links is inconsistent.

I think the two cases should be distinguished by the means of two separate props:

  • external: for links that point to non-core-admin pages
  • opensNewTab (better wording welcome): for links that open in a new browser's tab

Links may also change what or how data is displayed (i.e., view more, show all). If the action taken by the user will change or manipulate data, use a button. (Carbon)

That's really wrong. All those use cases must use <button> elements. Links must exclusively be used to render <a> elements (with valid href attribute) that trigger navigation to a new page. For no reason, ever, links should be used for actions or to "do something" in a page.

This is also part of an ongoing effort in WordPress core in the last few years, meant to eliminate links that are "not links". See https://core.trac.wordpress.org/query?keywords=~semantic-buttons. In short, the following usages, often tied to some kind of JavaScript interaction, are very bad practices and must be avoided:

  • <a href="#" ...
  • <a href="" ...
  • <a ...

Links are used to embed actions or pathways to more information in a sentence. (Polaris)

I'm not sure I understand what that means.

Current Core best practices that need to be implemented:

  • links that use target="_blank" need to inform users the link will open in a new tab: core uses the visually hidden text (opens in a new tab)
  • ideally, links that use target="_blank" should also convey an equivalent information visually; in some places in core these links use an icon (see for example the Events Dashboard widget or some links in Gutenberg) but this is a relatively new pattern and many similar links miss the icon

@mapk
Copy link
Contributor

mapk commented May 12, 2020

I'm closing out the Component Audit issues for now.

@mapk mapk closed this as completed May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system Needs Design Feedback Needs general design feedback. Needs Technical Feedback Needs testing from a developer perspective. [Package] Components /packages/components
Projects
None yet
Development

No branches or pull requests

4 participants