Skip to content

Conversation

@khushal87
Copy link
Member

@khushal87 khushal87 commented Aug 26, 2023

Motivation

Fixes #3824

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Jest Unit Test
  • Checked with example app

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation using yarn docs-build-api
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional context

@netlify
Copy link

netlify bot commented Aug 26, 2023

Deploy Preview for react-native-elements ready!

Name Link
🔨 Latest commit 8da88d0
🔍 Latest deploy log https://app.netlify.com/sites/react-native-elements/deploys/64f961e932f56300086a6a9d
😎 Deploy Preview https://deploy-preview-3831--react-native-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@khushal87 khushal87 requested a review from arpitBhalla August 26, 2023 06:25

let componentToRender;

if (source) {
Copy link

@haeniya haeniya Aug 26, 2023

Choose a reason for hiding this comment

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

If I unserstand correctly, in 4.0.0-rc.7, the title (if present) was shown in two different situations:

  1. As placeholder content when the image was rendering or could not be loaded
  2. As a fallback, if there was no image source passed (e.g. when the image source is undefined)
    See here: https://github.com/react-native-elements/react-native-elements/blob/v4.0.0-rc.7/packages/base/src/Avatar/Avatar.tsx#L206-L230

I wonder if this behavior is still the same with the latest changes.

There is a workaround for this (#3824 (comment)) but maybe we could keep the behavior the same? If this in on purpose and there are reasons to have it that way, it's fine for me. Just wanted to point that out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @haeniya I totally understand your concern. I was checking the implementation of Placeholder content but regardless of this change, it doesn't seem to render the content even if I pass a placeholder content directly to the Image component(I doubt this ever worked before). The issue might be different and can be addressed differently.

This PR sought to fix the multiple components render issue(that was a mistake) and rendering placeholder still remains an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I would say using the imageProps would be a more viable option since we have it in Avatar. Users can use the imageProp and pass PlaceholerContent into it. No point in introducing a new prop in avatar for the same.

Copy link

Choose a reason for hiding this comment

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

It worked in 4.0.0-rc.7 but doesn't in the 4.0.0-rc.8 release. But you're right, it could be handled in a different issue/PR. I was just wondering if we need to refactor the code anyway, why not fix that too (to maybe speed up the process a bit).

I think I would say using the imageProps would be a more viable option since we have it in Avatar. Users can use the imageProp and pass PlaceholerContent into it. No point in introducing a new prop in avatar for the same.

I think the idea would not be to introduce a new prop but to make the title prop the PlaceholderContent if present. The linked workaround works for me but I need to put the title twice, as PlaceholderContent and as title. Was quite convenient to have this fallback automatically.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @haeniya, I have pushed the icon as the placeholder component as per the docs. Hope that helps. Please review the PR, if you can and let me know if it works. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @haeniya, I am sorry for the confusion. I was luckily able to reproduce it now and I have pushed the fix. Hope that helps. Thanks 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

@haeniya if you have tested it well, can we merge it?

Copy link

Choose a reason for hiding this comment

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

@khushal87 I don't see any updates on the PR. Have you pushed your changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sorry my bad @haeniya, I thought I pushed it but I missed it somehow. Now I have done. Thanks 😄

Copy link

Choose a reason for hiding this comment

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

@khushal87 I just tested it and it looks good to me. Thanks for the update. 👍

@codecov
Copy link

codecov bot commented Aug 26, 2023

Codecov Report

Merging #3831 (3b56302) into next (b5a95f6) will increase coverage by 0.03%.
Report is 1 commits behind head on next.
The diff coverage is 92.85%.

❗ Current head 3b56302 differs from pull request most recent head 8da88d0. Consider uploading reports for the commit 8da88d0 to get more accurate results

@@            Coverage Diff             @@
##             next    #3831      +/-   ##
==========================================
+ Coverage   79.87%   79.91%   +0.03%     
==========================================
  Files          87       87              
  Lines        1824     1837      +13     
  Branches      814      809       -5     
==========================================
+ Hits         1457     1468      +11     
- Misses        362      364       +2     
  Partials        5        5              
Files Changed Coverage Δ
packages/base/src/Avatar/Avatar.tsx 95.74% <92.85%> (-4.26%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@arpitBhalla arpitBhalla merged commit 75d6ef7 into react-native-elements:next Sep 9, 2023
@l2aelba
Copy link

l2aelba commented Dec 14, 2023

How to install or update to this fix ? @khushal87

@l2aelba l2aelba mentioned this pull request Dec 15, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Both Icon and image show up in the picture

4 participants