#50335 closed defect (bug) (fixed)
Privacy Policy Guide page: Improvements for the Copy button
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.5 | Priority: | normal |
| Severity: | normal | Version: | 5.5 |
| Component: | Privacy | Keywords: | has-screenshots has-patch commit |
| Focuses: | accessibility, javascript | Cc: |
Description
I'd like to propose a few improvements for the "Copy" button in the Privacy Policy Guide page:
- The timeout used to make the "Copied!" text isn't cleared
- The Copy button visible text and
screen-reader-textare a bit too verbose - The Copy button and the "Return to Top" visual order and DOM order don't match
- Maybe consider to use
ClipboardJSrather than a custom implementation
1
When clicking the Copy button, a "Copied!" text appears to provide a visual confirmation. A setTimeout() is used to make this text disappear after 3 seconds. However, the timeout isn't cleared. When users click the Copy button multiple times within the 3 seconds interval, the text appearing / disappearing behavior becomes... interesting because a new timeout is set at each click. See first animated GIF attached below.
While this is an edge case, it's also easy to fix. Also, as a best practice setTimeout() should be used with care and in most cases needs to be cleared.
2
I do realize the good intent by providing some screen-reader-text for the button. However, the whole text string made of the visible and hidden text is too verbose and a bit redundant. Each time screen reader users will land on this button and each time they activate it they will hear the whole text being announced:
Copy this section to clipboard Copy suggested policy text from WordPress.
See second animated GIF attached below.
I'd just simplify and remove the screen-reader-text.
3
According to the W3C Web Content Accessibility Guidelines, visual order and DOM order must always match when the sequence "affects meaning or operation".
In this page, the "Return to Top" link is visually presented after the Copy button but in the source it's before the button. Thus, keyboard navigation can be confusing for users. I don't see a special reason why "Return to Top" should come first in the source so I'm guessing it's just a matter of moving it in a more correct order. Also, I'd tend to think a "Return to Top" link should always come after any other control related to a specific page.
References;
1.3.2 Meaningful Sequence (Level A) https://www.w3.org/TR/WCAG21/#meaningful-sequence
2.4.3 Focus Order (Level A) https://www.w3.org/TR/WCAG21/#focus-order
4
Lastly, I'd like to propose to consider to use ClipboardJS rather than a custom implementation. ClipboardJS would allow for a simpler implementation even if it needs a couple fixes for better accessibility. See #50322 and ticket:48463#comment:38
Attachments (5)
Change History (19)
#1
@
6 years ago
Thanks @afercia I'll look through when I can. Just sharing some related tickets for background;
#44588 - We attempted ClipboardJS but reverted back in order to preserve formatting and not require another element or attribute to contain a stripped down version of the content.
#44677 - We changed the button text to 'Copy this section to clipboard' to be explicit.
#49540 - Fixed a quick regression after the above tickets were merged.
#2
@
6 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 5.5
- Version set to trunk
Thanks @garrett-eclipse, I went through #44588 and now have a better understanding of all the bits around this functionality.
I'd say to start simple :) 50335.diff:
- clears the timeout when clicking the button
- minor JS coding standards
- makes the visual order match the DOM order
- improves the
return-to-toplink: link should never use ahrefattribute with only a#: that's just an incomplete URL fragment identifier, see the accessibility coding standards https://developer.wordpress.org/coding-standards/wordpress-coding-standards/accessibility/#semantics-for-controls - removes the redundant
screen-reader-text - hides the up arrow
↑as it was unnecessarily announced by screen readers
Regarding keeping the formatting in the copied text: I do think ClipboardJS can do that when set up correctly. I saw on #44588 that data-clipboard-target was already tried. There's also the option to pass a DOM element, see https://github.com/zenorocha/clipboard.js#advanced-options. Also, ClipboardJS has an internal method to clear the selection that can be used after a successful copy action so the "highlighted" text can be de-selected.
I'd still lean towards trying ClipboardJS. Internally, it uses the same methods used in this custom implementation so I don't see a reason to not use it :) The advantage is that it does that in a more standardized way. Also to evaluate: a WP wrapper method around ClipboardJS as mentioned in #50322. Noting that also @xkon mentioned moving to ClipboardJS should still be a goal and at that time it was postponed to a future ticket yet to come. I'd reserve this attempt to a next iteration on this ticket.
Aside: any reason why the privacy CSS is in the edit.css file? common.css seems more appropriate to me.
This ticket was mentioned in Slack in #accessibility by audrasjb. View the logs.
6 years ago
#6
@
6 years ago
- Keywords needs-refresh needs-testing added
Marking for refresh as the patch doesn't apply cleanly anymore.
#7
@
6 years ago
- Keywords needs-refresh removed
The patch still applied for me, using grunt patch with only 1 line offset in edit.css. Usually, this kind of issues aren't a big concern and can be checked during commit, if needed. I refreshed the patch anyways.
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
6 years ago
#12
@
6 years ago
50335.3.diff refreshes the patch. Keeps the custom implementation. I'd still think this button should use ClipboardJS for a consistent implementation in core, but that can be explored in future iterations.
Clicking the Copy button multiple times: observe the "Copied!" text behavior