Skip to content
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

feat: Add alt prop to Image component #34550

Closed

Conversation

gabrieldonadel
Copy link
Collaborator

@gabrieldonadel gabrieldonadel commented Aug 31, 2022

Summary

This adds the alt prop to the Image component as requested on #34424. Using this new alt prop enables the accessibility prop and passes down the alt text to accessibilityLabel. This PR also updates RNTester ImageExample in order to facilitate the manual QA.

Open questions

  • On web alt text is displayed on the page if the image can't be loaded for some reason, should we implement this same behavior if the Image component fails to load source? Not for now

Changelog

[General] [Added] - Add alt prop to Image component

Test Plan

  1. Open the RNTester app and navigate to the Image page
  2. Test the alt prop through the Accessibility Label via alt prop section, this can be tested either by enabling Voice Over if you're using a real device or through the Accessibility Inspector if you're using a simulator
Screen.Recording.2022-08-31.at.18.41.15.mov

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Aug 31, 2022
@react-native-bot react-native-bot added the Type: Enhancement A new feature or enhancement of an existing feature. label Aug 31, 2022
@analysis-bot
Copy link

analysis-bot commented Aug 31, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,728,076 +509
android hermes armeabi-v7a 7,130,955 +502
android hermes x86 8,034,620 +492
android hermes x86_64 8,007,908 +501
android jsc arm64-v8a 9,597,281 +363
android jsc armeabi-v7a 8,363,583 +354
android jsc x86 9,541,506 +355
android jsc x86_64 10,133,905 +358

Base commit: 8cdc9e7
Branch: main

@analysis-bot
Copy link

analysis-bot commented Aug 31, 2022

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 8cdc9e7
Branch: main

@ryancat
Copy link
Contributor

ryancat commented Sep 1, 2022

On web alt text is displayed on the page if the image can't be loaded for some reason, should we implement this same behavior if the Image component fails to load source?

It's tricky, but I think we should do it.

Pros:

  • There's no hover with mobile screens, so the alt really can only be rendered into words, instead of using a placeholder image with hovered text
  • Matching web spec

Cons:

  • Mobile screen is much smaller, and we need to avoid super long alt that breaks user experiences unexpectedly (How web handles super long alt?).

@necolas
Copy link
Contributor

necolas commented Sep 1, 2022

At this stage, I don't think we need to display the alt text if the image doesn't load. Often on web we try to prevent broken images breaking layout by hiding fallback text anyway. This is what RNWeb does today. We can always revisit this decision in the future once people start using it and if a case is made.

@gabrieldonadel gabrieldonadel requested review from necolas and removed request for ryancat September 2, 2022 02:10
@gabrieldonadel gabrieldonadel requested review from ryancat and removed request for necolas September 5, 2022 18:41
@necolas
Copy link
Contributor

necolas commented Sep 6, 2022

Ping @cipolleschi or @jacdebug to import

@gabrieldonadel gabrieldonadel force-pushed the feat/add-alt-to-image branch 2 times, most recently from 34db210 to 2490538 Compare September 8, 2022 15:40
@gabrieldonadel
Copy link
Collaborator Author

Could someone please import this? @cipolleschi @NickGerleman @jacdebug @ryancat

@gabrieldonadel gabrieldonadel force-pushed the feat/add-alt-to-image branch 2 times, most recently from 53027c8 to f551198 Compare September 9, 2022 19:02
@gabrieldonadel gabrieldonadel requested review from necolas and removed request for ryancat September 16, 2022 16:19
@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@lunaleaps lunaleaps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also update the TS types?

@gabrieldonadel
Copy link
Collaborator Author

Can we also update the TS types?

Sure, I've just updated it

@necolas
Copy link
Contributor

necolas commented Sep 20, 2022

The TS types are already out of sync with the Flow types, as they don't have props from the other merged Web PRs

@lunaleaps
Copy link
Contributor

lunaleaps commented Sep 20, 2022

The TS types are already out of sync with the Flow types, as they don't have props from the other merged Web PRs

I'm actively updating them to catch up (like the accessibility, id ones) and for going forward, we can keep them up to date.

facebook-github-bot pushed a commit that referenced this pull request Sep 22, 2022
Summary:
While working on #34550 I noticed that a couple of words inside the RNTester package were misspelled, this gave me the idea to test other files as well using the VS Code extension [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) which unveiled quite a few other typos.

## Changelog

[Internal] [Fixed] - Fix RNTester typos

Pull Request resolved: #34757

Test Plan: Shouldn't require much testing as this is just fixing some typos inside the RNTester package.

Reviewed By: dmytrorykun

Differential Revision: D39722889

Pulled By: cortinico

fbshipit-source-id: a575ab8337586c5fe2d68ce73d2aae27d24a6384
@cipolleschi
Copy link
Contributor

Hi @gabrieldonadel could you please fix the linting warning? After that I'll reimport this. ;)

@gabrieldonadel
Copy link
Collaborator Author

Hi @gabrieldonadel could you please fix the linting warning? After that I'll reimport this. ;)

Sure thing, you're talking about these lint warnings that the github-actions bot commented, right?

@gabrieldonadel
Copy link
Collaborator Author

Hi @gabrieldonadel could you please fix the linting warning? After that I'll reimport this. ;)

@cipolleschi I've pushed a commit fixing all warnings

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @gabrieldonadel in 71fda5e.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 27, 2022
@gabrieldonadel gabrieldonadel deleted the feat/add-alt-to-image branch September 27, 2022 12:06
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
While working on facebook#34550 I noticed that a couple of words inside the RNTester package were misspelled, this gave me the idea to test other files as well using the VS Code extension [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) which unveiled quite a few other typos.

## Changelog

[Internal] [Fixed] - Fix RNTester typos

Pull Request resolved: facebook#34757

Test Plan: Shouldn't require much testing as this is just fixing some typos inside the RNTester package.

Reviewed By: dmytrorykun

Differential Revision: D39722889

Pulled By: cortinico

fbshipit-source-id: a575ab8337586c5fe2d68ce73d2aae27d24a6384
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
This adds the `alt` prop to the `Image` component as requested on facebook#34424. Using this new `alt` prop enables the `accessibility` prop and passes down the alt text to `accessibilityLabel`. This PR also updates RNTester ImageExample in order to facilitate the manual QA.

#### Open questions
 - ~~On web `alt` text is displayed on the page if the image can't be loaded for some reason, should we implement this same behavior if the `Image` component fails to load `source`?~~ Not for now

## Changelog

[General] [Added] - Add alt prop to Image component

Pull Request resolved: facebook#34550

Test Plan:
1. Open the RNTester app and navigate to the Image page
2. Test the `alt` prop through the `Accessibility Label via alt prop` section, this can be tested either by enabling Voice Over if you're using a real device or through the Accessibility Inspector if you're using a simulator

https://user-images.githubusercontent.com/11707729/187790249-0d851363-c30e-41b6-8c24-73e72467f4ba.mov

Reviewed By: lunaleaps

Differential Revision: D39618453

Pulled By: cipolleschi

fbshipit-source-id: 0e26b2574514e76ce7e98ddb578f587a9cc30ee9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Type: Enhancement A new feature or enhancement of an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants