-
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
Post Preview Button: Use an <a> instead of a <button> #11187
Conversation
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.
Code looks good. Some really nice refactoring! The only usability thing I spotted is that the link can now not be opened using the spacebar, which feels like an inconsistency given that it's visually perceived as a button. I imagine users might have an expectation that it can be used in the same way as the 'Publish' button next to it.
@noisysocks what do you think?
@talldan: That's a good point. I wonder if we should do this for all |
Would be good to get an idea on whether it's considered a blocker for this PR as well. |
I don't know that the spacebar behavior should be a blocker here, as it applies to any I'm not sure what the correct answer is to the spacebar behavior of a link which takes the aesthetic of a button. I imagine the answer could include some commentary to the point of: maybe we should stop making links look like buttons. See also #7534. Maybe worth creating an issue or consolidating to #7534 to be discussed separate to the effort here? |
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'll approve given the spacebar issue isn't considered a blocker.
Thanks Dan. We can address any follow-up issues as seperate PRs. |
Yep, the spacebar thing is a broader issue across the whole WordPress UI, definitely not a blocker for this PR. Thanks everyone for working on this. |
Fixes #9446.
Changes
PostPreviewButton
to use an<a>
element when possible. Although we always intercept theonClick
event, having the button rendered as an<a>
withhref
andtarget
attributes helps with accessibility, see #9446 (comment) for a great explanation on why.As part of this, I've moved some code around and written some inline comments with an aim to make
openPreviewWindow
easier to comprehend.Testing
I've updated the unit tests for
PostButtonPreview
.The existing E2E test should serve as an acceptance test for these changes.
To test manually: