-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
<Picture> component should pass all unknown attributes to the <img> element #3961
Conversation
🦋 Changeset detectedLatest commit: ab6a569 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 |
9bbde4c
to
5174b6b
Compare
<picture> | ||
{sources.map(attrs => ( | ||
<source {...attrs} {sizes}>))} | ||
<img {...image} {loading} {decoding} /> | ||
<img {...image} {...attrs} {loading} {decoding} /> | ||
</picture> |
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.
How would this play out with Tailwind, which heavily uses the class
attribute?
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.
class
should be passed down to the img
element here, so <Picture class="rounded-sm" />
would result in <picture><img class="rounded-sm" /></picture>
I'd expect styling the img
is the common case rather than styling the picture
itself, but do you have a use case in mind? Happy to reconsider exposing a way to add props to the picture
and img
separately if that's useful!
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.
Yea, this feels tough to understand for a user. If I add attribute X
, how do I know which element that's being applied to? Could you apply it to both?
fwiw I know we discussed the other week that the <Picture>
isn't as high of a priority as the other things on our plate for v1.0. I'd love to deprioritize anything <Picture>
related and revisit once we're either closer to v1.0 or even post v1.0.
Alternative, I could see a smaller quick fix that just moves the alt
attribute to img
, but leaves all remaining attributes as-is.
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.
Fair enough! Rolled this back to only pass down the alt
text to fix accessibility concerns, we can revisit the expected behavior for other attributes later
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.
…mg> element" This reverts commit ce3e339.
5174b6b
to
ef430f2
Compare
Closes #3909
Changes
This updates the
<Picture />
component to pass any unused attributes directly to the<img />
elementCurrent behavior is that the attributes are added to the
<picture>
but this is a really uncommon use case and breaks accessibility since there is no way currently to addalt
to the picture'simg
Testing
Tests updated to verify custom
<img />
attributes are includedDocs
Integration's README updated with a note on how to add attributes to the picture's
<img>
element