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

Add an icon and visually hidden a11y text to links that open in a new tab #7883

Merged
merged 17 commits into from
Jul 24, 2018

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Jul 11, 2018

Description

Closes #1105

Adds an icon and the visually hidden text '(Opens in a new window)' for improved a11y to two links that open in a new tab.

  • Use ExternalLink component for the link editor toolbar option on the Paragraph block. It replaces an a tag. This adds an additional icon and the visibly hidden text to the url.
  • Use the ExternalLink component for the permalink url when editing the post header

Furthermore a change has been made to the preview button in the top toolbar so that is a button element instead of an anchor.

How has this been tested?

  • Manually tested visual appearance of icon
  • Manually tested 'Opens in a new window' a11y text using VoiceOver
  • Ensured automated tests pass

Screenshots

Permalink:
screen shot 2018-07-17 at 11 14 39 am

Preview (visually unchanged, but is now a button element):
screen shot 2018-07-17 at 11 14 56 am

Paragraph Block Link:
screen shot 2018-07-17 at 11 14 50 am

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@talldan talldan self-assigned this Jul 11, 2018
@talldan talldan added [Type] Bug An existing feature does not function as intended [Type] Task Issues or PRs that have been broken down into an individual action to take [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Component] Button labels Jul 11, 2018
@talldan
Copy link
Contributor Author

talldan commented Jul 11, 2018

@karmatosed Would be great if you could just double-check the screenshots look ok. The only thing I spotted is that the link text color isn't the same for the permalink and the rich text link. I can make a separate issue if you think that's worth making consistent.

@talldan talldan requested a review from noisysocks July 11, 2018 04:53
@@ -181,6 +181,15 @@
padding: 0 8px 1px;
font-size: 11px;
}

.components-external-link__icon {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't entirely sure that these are the right selectors to use, or whether I should somehow specify a class of components-button__icon on the icon.

Copy link
Member

@noisysocks noisysocks Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class should begin with components-button__ since the element is in the Button component.

@talldan
Copy link
Contributor Author

talldan commented Jul 11, 2018

ah - I need to add some tests, particularly on the button element. Will add some asap.

@noisysocks
Copy link
Member

Very supportive of the changes to the link formatting tool and permalink editor here. It looks great 👍

I'm not so sure about changing the Preview button, though.

In my mind1, the point of the external icon is to shape the user's expectation so that they're not surprised when a new tab opens. This makes total sense since the expectation when clicking a hyperlink is that the browser navigates to a new page in-place.

But I don't think users have any such expectations when they click on a button. A button doesn't imply that clicking it will navigate to a new page. It's a button—buttons can do anything!

Could an alternative to this be to make the Preview button a <button> instead of an <a>? Or, could we add we add aria-role="button" and have it open when a user selects it and presses Space?

1 Read: I am not a UX designer! 🙂

@noisysocks noisysocks added the Needs Design Feedback Needs general design feedback. label Jul 11, 2018
Copy link
Member

@karmatosed karmatosed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noisysocks is hereby granted temporary 'UX designer' status as he was on point with suggesting this doesn't get done to the preview button :) I would say apart from that so long as things are just links (not buttons hiding in link clothing) this is a great improvement.

@@ -83,6 +83,7 @@ class PostPermalink extends Component {
href={ ! isPublished ? postLink : samplePermalink }
target="_blank"
ref={ ( permalinkButton ) => this.permalinkButton = permalinkButton }
isExternalLink
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than modifying Button, could we just make PostPermalink use an ExternalLink component? It doesn't look like we need any Button functionality in this case, and I'm wary of Button becoming a component that has too many responsibilities.

<ExternalLink
	className="editor-post-permalink__link"
	href={ ! isPublished ? postLink : samplePermalink }
	ref={ this.permalinkRef }
/>

(To make the above work, we'll likely need to make ExternalLink forward refs.)

@afercia
Copy link
Contributor

afercia commented Jul 16, 2018

and I'm wary of Button becoming a component that has too many responsibilities.

This is the main reason why a previous attempt in #6786 was abandoned. It ended up in adding a lot of stuff to the Button component. Currently, the Button component is named based on its visual appearance. This is far from ideal and introduces some potential confusion. Components should be named based on what they do. In the discussion on #6786 (comment) at some point it was agreed to split the Button component in two separate components, in short:

  • Link: it's an <a> element, used to navigate to a web resource (i.e. no href="#" links used to "do something") and visually styled as a link or a button
  • Button: it's a <button> element, used to "do something" and visually styled as a button or link

Based on that #7534 was created to separate the two components and eliminate ExternalLink. I know that takes a different path from the work done here, sorry for that, but I'd strongly encourage to focus on the effort proposed on #7534.

@talldan
Copy link
Contributor Author

talldan commented Jul 16, 2018

Agree that separate components would be nice, I've addressed most of the feedback now.

Will take a look at this failing test tomorrow.

Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the failing test this looks great! 🙂

@noisysocks
Copy link
Member

It looks like the failing test was just an intermittent E2E test failure. I restarted the job for you.

@talldan
Copy link
Contributor Author

talldan commented Jul 17, 2018

Great - thanks @noisysocks.

@karmatosed - I've updated the screenshots at the top, are you happy to approve this now?

@talldan
Copy link
Contributor Author

talldan commented Jul 17, 2018

Btw, I spotted a bug - the edit link popover in paragraph blocks doesn't always open in the right place (It's ok the first time you select a link, but the second time it goes wandering off). That bug is present in master so I'll make a separate issue for it (#7992).

@karmatosed
Copy link
Member

@talldan do we need to have the link icon in the actual link interface? That feels over the top to me.

@talldan
Copy link
Contributor Author

talldan commented Jul 18, 2018

@karmatosed - do you mean this icon?

external link

I thought that was one of the main points we were trying to address from #1105. My opinion is that we should use the icon consistently on anything that looks like and interacts like a link.

I think in any case where a user might be concerned about losing their state or unsaved changes it's good to indicate the link will launch in a new tab.

@karmatosed
Copy link
Member

@talldan my understanding was that it was for interface links not links in the drop down. It's this bit I am questioning:

2018-07-18 at 14 12

If everyone wants that's ok it just feels a little odd seeing beside something like this.

Links added in RichText are opened in a new tab when using the editor toolbar.
This commit switches the anchor tag with an ExternalLink component. This makes
the link more accessible (it adds some hidden text) and provides an icon
indicating that the link is external.
For accessibility purposes the post preview button is now rendered as a button,
meaning it can be interacted with using the keyboard (space bar to open a
preview page).
… for scss selectors"

This reverts commit 77422fce000a2b75788b5fadaa1cd26e770799e3.

Revert "Add tests for isExternalLink prop in Button component"

This reverts commit 5102826e2c22c7ae59c8d21a3b1fb44781babe5f.

Revert "Use flex to center icon in button and add a tiny bit of margin to adjust"

This reverts commit 0f3c5fa792dc3386e05acd3821ea32b245b42377.

Revert "Set isExternalLink true for post permalink and adjust styling"

This reverts commit 402ecd3ff93f3b945072124f4bd47e15fb3470ce.

Revert "Position dashicon for external links when rendered via Button"

This reverts commit 0930efac6c9eb709b5af7e0e28e9d05d3346bebd.

Revert "Allow Button component to render an ExternalLink"

This reverts commit 1b8e9ca5c5fe67aab5d08d2ffc0798fb7edfaa8d.

Revert "Add prop for icon class name to ExternalLink"

This reverts commit ddac73dd0f09a1076f842fdb89ece370e274ac82.
@talldan
Copy link
Contributor Author

talldan commented Jul 23, 2018

@karmatosed My feeling is that it should be consistent across links. I'm happy for you to make a call and I'll make the necessary changes. Here's a gif so you can see what it looks like in action:
external-link-paragraph-block

@karmatosed
Copy link
Member

Let's add it in @talldan and iterate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Links that open in a new tab/window need to inform users a new tab/window will open
4 participants