-
Notifications
You must be signed in to change notification settings - Fork 116
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
ClipboardCopy
only needs aria-label
when empty
#1244
ClipboardCopy
only needs aria-label
when empty
#1244
Conversation
🦋 Changeset detectedLatest commit: 88bb2d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
cc44bb0
to
ada775e
Compare
@@ -34,10 +34,16 @@ def initialize(value: nil, **system_arguments) | |||
@system_arguments[:value] = value if value.present? | |||
end | |||
|
|||
# :nodoc: | |||
def render_in(*args, &block) | |||
validate_aria_label unless block_given? |
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.
Hmm, I'm not sure checking the presence of a block is the right approach here. The component could ostensibly be passed an empty block, or someday have slots that must be defined in the block. What would you think about something like:
def before_render
validate_aria_label if content.blank?
end
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.
They can always give some content that is not suitable for screen readers, but explicitly checking for blank sounds good. before_render
also sounds like a better place for this check than hooking into render_in
as well.
38faf06
to
c8a1fb6
Compare
We were requiring `aria-label` on ClipboardCopy in all cases, but when the component already contains suitable text this is not recommended. This changes when we validate the presence of `aria-label`. At instantiation time the component doesn't know if it will be rendered with a block, so we check at render time instead. Fixes primer#1081
I was just checking for a block to decide if ClipboardCopy needed an aria-label. But @camertron suggested that checking for blank content would be better, and I think the code is nicer as well.
c8a1fb6
to
0a5cb86
Compare
An explicit nil tests just as well while satisfying the linter.
69d09d1
to
88bb2d4
Compare
We were requiring
aria-label
onClipboardCopy
in all cases, but when the component already contains suitable text this is not recommended.This changes when we validate the presence of
aria-label
. At instantiation time the component doesn't know if it will be rendered with a block, so we check at render time instead.Fixes #1081