-
Notifications
You must be signed in to change notification settings - Fork 72
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
Feature request: aria-hidden
#72
Comments
Perhaps this is a good issue for a |
@tysongach thanks for taking the time to write up this suggestion. I'm generally 👍 on any feature that improves things from an accessibility perspective. As for the interface, my preference would be to make this an explicit option, requiring a value. E.g. <%= inline_svg "icon.svg", aria_hidden: true %> |
@jamesmartin @tysongach is this already supported? inline_svg/spec/helpers/inline_svg_spec.rb Lines 132 to 141 in 25fa64e
Could something like this work? <%= inline_svg "icon.svg", "aria-hidden" => true %> |
@seanpdoyle it's possible to implement via custom transformations, but each user of the gem would have to implement their own version. Is that what you had in mind? |
@jamesmartin for custom attribute support, are there additional steps to take other than <%= inline_svg "icon.svg", "aria-hidden" => true %> |
I should’ve been more clear in my original description, but yes, this is possible today via custom transformations: class AriaHiddenAttribute < InlineSvg::CustomTransformation
def transform(doc)
doc = Nokogiri::XML::Document.parse(doc.to_html)
svg = doc.at_css "svg"
svg["aria-hidden"] = value
doc
end
end
InlineSvg.configure do |config|
config.add_custom_transformation(
attribute: :aria_hidden,
transform: AriaHiddenAttribute,
)
end This allows you to pass a |
@seanpdoyle yes, see @tysongach's example code. |
Closes [jamesmartin#72]. Sometimes SVGs are simply decorative and therefore should be removed from the accessibility tree. Here’s an example: ```erb <p> <%= inline_svg "checkmark-icon.svg" %> Success! </p> ``` You can imagine this as a simple flash message, letting the user know that their action succeeded. We have the word ‘Success’, preceded by a checkmark icon to visually represent the state. In such a situation, the icon is simply decorative; it’s repeating content already conveyed by the word ‘Success.’ If we apply `aria-hidden="true"` to the SVG, we can remove it from the accessibility tree and avoid the repetition. [jamesmartin#72]: jamesmartin#72
@seanpdoyle thanks for opening the PR for this. Great minds think alike, I think we both just implemented the same thing. See #78 😁 I'll merge yours so you get the contribution credit. |
👋
Huge high-fives all-around for the accessibility features this gem already offers. It’s so handy to be able to pass in titles and descriptions when you call on an SVG. I’d like to discuss furthering the accessibility features by allowing the hiding of SVGs using
aria-hidden
.Sometimes SVGs are simply decorative and therefore should be removed from the accessibility tree. Here’s an example:
You can imagine this as a simple flash message, letting the user know that their action succeeded. We have the word ‘Success’, preceded by a checkmark icon to visually represent the state.
In such a situation, the icon is simply decorative; it’s repeating content already conveyed by the word ‘Success.’ If we apply
aria-hidden="true"
to the SVG, we can remove it from the accessibility tree and avoid the repetition.Possible solution?
I’ve not dug into the specifics of how the
aria
option works, but perhaps passing it ahidden
value could work (edit: see comment below):The text was updated successfully, but these errors were encountered: