-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix incorrectly displayed preview option for private post types #20604
Conversation
Size Change: -16 B (0%) Total Size: 863 kB
ℹ️ View Unchanged
|
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.
Thanks for fixing this! Tested with a custom post type, it's working well. Just one small CSS change suggested below 🙂
<> | ||
{ __( 'Preview externally' ) } | ||
<Icon | ||
icon={ external } |
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.
Oooh I didn't know we could pass components into textContent
🤯
@@ -53,7 +53,7 @@ | |||
|
|||
.editor-post-preview__button-external { | |||
height: $button-size; | |||
display: block; | |||
display: flex; |
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.
If we add justify-content: space-between
here we can remove the below .editor-post-preview__icon-external
rule altogether.
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.
Nice, that's a good little improvement 👍
3a209d3
to
67d6ef4
Compare
const previewButtons = await page.$$( | ||
'.editor-post-preview__button-resize' | ||
); | ||
expect( previewButtons.length ).toBe( 3 ); |
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 wondering if we really need to check how many menu groups and resize buttons display in this test. Those things could change in the future, and this test shouldn't fail unless "Preview Externally" is actually showing.
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've changed it so that it now only checks for the link.
The reason I wrote it like that originally is that I wanted to be able to check for regressions of this bug, and the bug is that the menu group and icon are displayed. I wouldn't be able to add assertions for the menu group or icon without adding some kind of unique identifier to them.
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.
Oh, I see. I wonder if a snapshot test would be a better way of checking for that scenario. If we did change the markup, we'd be expecting snaphsots to fail anyway.
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 personally feel like this is fine as it is. The test wouldn't be perfect, but it'd catch the most important failure, the presence of the link.
Snapshots for individual pieces of UI in end to end tests is a little outside of the norm, and while I'm not against it, it'd mean the snapshot needed to be updated for any minor unrelated change. That seems like it'd be a slower/more regular process than updating the element counts that were here previously.
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.
No worries!
I was thinking a snapshot as part of the unit tests, but that doesn't need to be part of this changeset.
efe11a5
to
aa56f89
Compare
Description
For private post types, the preview link is not normally displayed. The new preview menu isn't displaying this correctly though—while the Preview Externally link is (correctly) not displayed, the Open In New Tab icon is still being shown along with the surrounding menu group.
This PR fixes that to hide the menu group that contained the Preview externally link completely for non-viewable posts.
It also moves the Open In New Tab icon so that it's within the anchor element, whereas before it wasn't clickable.
How has this been tested?
Added e2e tests.
Manual Testing steps:
Screenshots
Before:
After:
Types of changes
Checklist: