-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Site Editor: Add page details when viewing a specific page. #48650
Conversation
@@ -49,7 +49,14 @@ export default function SidebarNavigationScreenNavigationItem() { | |||
/> | |||
} | |||
content={ | |||
post ? decodeEntities( post?.description?.rendered ) : null | |||
<> | |||
<a href={ post?.link } target="_blank" rel="noreferrer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a component we can use instead of a normal link?
We need to change the style of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be overkill, but we could use the <Button />
component. It looks like if you pass it a href
it will output it as an <a>
element. The Preview link in the page editor uses the <PostPreviewButton />
which wraps the wp components <Button />
which outputs an <a>
element if it has an href.
So, I think directly using an <a>
is fine. If we want to style it (and the <Button />
has a default that works for us, add tooltips, aria elements, and state, etc, then the <Button />
component could be a good option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a11y-wise it's best not to open links in a new tab without warning:
It is recommended that when links are opened to a new window, there is advance warning.
https://www.w3.org/TR/WCAG20-TECHS/G200.html
Using the <Button />
element doesn't look like it automatically handles adding a visually-hidden warning if you pass an href and a target="_blank"
, but there may be another component that does. I'm looking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. The the component @richtabor mentioned in the issue: ExternalLink
lol. I'll update the PR.
Size Change: +163 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7e5d717. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4306324775
|
For improved a11y without extra effort, let's use the ExternalLink component as it already meets WCAG specs/best practices for warning a user when a link will be opened in a new page. https://www.w3.org/TR/WCAG20-TECHS/G200.html
Switched from the blue to a gray link. Added hover and focus styles as well. Checked color contrast and it meets WCAG AA level.
} | ||
|
||
.components-external-link__icon { | ||
margin-left: $grid-unit-5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't build for me, I get:
'Error: Undefined variable.\n' +
' ╷\n' +
'22 │ margin-left: $grid-unit-5;\n' +
' │ ^^^^^^^^^^^^\n' +
' ╵\n' +
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a fix for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this isn't part of the component itself. It might be worth looking into a more general fix for the component, in a followup PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this isn't part of the component itself. It might be worth looking into a more general fix for the component, in a followup PR...
I think it's cause this can be used in smaller inline text, where its not necessary to add space before the icon. Although we probably should have some space after the icon in the screenshot:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a fix for this
Did you push it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops no, I have now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird — it both built and showed a space as if it was working for me 🤷🏻 Thanks for catching and fixing that!
packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js
Show resolved
Hide resolved
Thanks for the fixes @jeryj, I'm happy for this to be merged if you are :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just cherry-picked this PR to the wp/6.2 branch to get it included in the next release: 0641bce |
* Show the post link * Open in new window * Use ExternalLink component for link For improved a11y without extra effort, let's use the ExternalLink component as it already meets WCAG specs/best practices for warning a user when a link will be opened in a new page. https://www.w3.org/TR/WCAG20-TECHS/G200.html * Style link to use gray color Switched from the blue to a gray link. Added hover and focus styles as well. Checked color contrast and it meets WCAG AA level. * fix the grid unit variable name --------- Co-authored-by: Jerry Jones <[email protected]>
What?
This adds the URL of the current page when previewing a page in the Site Editor.
Fixes #48482 (comment)
Why?
This gives additional context when editing a page and also makes it possible to preview the page.
How?
Get the URL from the post data.
Testing Instructions
Screenshots or screencast