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

[ANDROID] Carousel loop doesn't behave correctly #2778

Open
2 of 3 tasks
baselshlewett opened this issue Oct 25, 2023 · 14 comments
Open
2 of 3 tasks

[ANDROID] Carousel loop doesn't behave correctly #2778

baselshlewett opened this issue Oct 25, 2023 · 14 comments
Assignees
Labels
bug a bug in one of the components

Comments

@baselshlewett
Copy link

baselshlewett commented Oct 25, 2023

Description

Auto play(loop) carousel on android jumps through indexes randomly and at most shows only 2-3 items, for example in an array of 18 items, it will only show indexes 0,1 and then jump to 17.

Expected behavior

Carousel should loop through all items as defined by items rendered

Actual behavior

Carousel jumps through items at random and at most shows only 2-3 items

Code snippet

<Carousel
    loop={true}
    autoplay={true}
    autoplayInterval={5000}
    showCounter={true}>
        {article?.multi_images?.map((item: string, index: number) => {
             return (
                 <Card.Image
                      key={index}
                      source={{uri: `${Config.ASSETS_URL}${item}`}}
                      cover={true} 
                      aspectRatio={1.34}
                      style={{
                          borderTopLeftRadius: 15,
                          borderTopRightRadius: 15,
                          borderBottomLeftRadius: article?.has_tickers ? 0 : 15,
                          borderBottomRightRadius: article?.has_tickers ? 0 : 15,
                      }}
                  />
              );
          })}
</Carousel>

Environment

  • React Native version: 0.72.6
  • React Native UI Lib version: 7.9.1

Affected platforms

  • Android
  • iOS
  • Web
@baselshlewett baselshlewett added the bug a bug in one of the components label Oct 25, 2023
@baselshlewett
Copy link
Author

Hello all, Any updates regarding this? or any work-around? As we're preparing to go to production

@nitzanyiz
Copy link
Contributor

Hi, this was a bug when using android in rtl. It will be fixed in the next release.

@baselshlewett
Copy link
Author

Hi, this was a bug when using android in rtl. It will be fixed in the next release.

Thank you @nitzanwix, let me know if I can help with anything

@baselshlewett
Copy link
Author

@nitzanwix I just managed to update to the latest version, and while the original issue is solved on android, I'm now observing the same issue on iOS.

And as a side-effect to the fix, now text inside RTL carousel is mirrored:

Screenshot 2023-12-13 at 13 03 09
Screenshot 2023-12-13 at 13 03 24

@nitzanyiz
Copy link
Contributor

Hi, Thanks you're response. I see the inverted text bug. Can you elaborate on what you're now experiencing on ios? I don't see any jumps on my end.

@baselshlewett
Copy link
Author

I observed the same behavior as in the original ticket, only this time was on [email protected].

For the time being I reverted to version [email protected] as I need to release to production.. I will do further tests after the release, and probably during the weekend and post the results here.

@baselshlewett
Copy link
Author

baselshlewett commented Dec 15, 2023

Hey @nitzanwix, I can confirm I'm experiencing the same behaviour as the original ticket on iOS

Environment

  • React Native version: 0.73.0
  • React Native UI Lib version: 7.12.2

On android, in addition to text being mirrored, I can see the the carousel direction is also reversed on RTL..

Let me know if I can provide any more details
Have a nice weekend

@nitzanyiz
Copy link
Contributor

Thanks for the reply. Could you show me how you use the carousel? (Code). Do you use autoplayInterval by any chance?

@baselshlewett
Copy link
Author

Thanks for the reply. Could you show me how you use the carousel? (Code). Do you use autoplayInterval by any chance?

Yes, I am.

I'm also forcing RTL through native code if that helps.

here is my implementation:
inside component/Card.tsx:

<Carousel
    key={article.multi_images.length ?? 0}
    autoplay={true}
    autoplayInterval={5000}
    itemSpacings={Spacings.s3}
    initialPage={0}
    showCounter={true}
    >
    {article?.multi_images?.map((item: string, index: number) => {
        return (
            <Card.Image
                key={index}
                source={{uri: `${IMAGE_URL}`}}
                cover={true}
                aspectRatio={1.34}
                style={{
                    borderTopLeftRadius: 15,
                    borderTopRightRadius: 15,
                    borderBottomLeftRadius: article?.has_tickers
                        ? 0
                        : 15,
                    borderBottomRightRadius: article?.has_tickers
                        ? 0
                        : 15,
                }}
            />
        );
    })}
</Carousel>

MainApplication.kt (previously MainApplication.java):

val sharedI18nUtilInstance: I18nUtil  = I18nUtil.getInstance()
sharedI18nUtilInstance.forceRTL(this,true)
sharedI18nUtilInstance.allowRTL(this, true);

AppDelegate.mm:

[[RCTI18nUtil sharedInstance] allowRTL:YES];
[[RCTI18nUtil sharedInstance] forceRTL:YES];

@nitzanyiz
Copy link
Contributor

nitzanyiz commented Jan 1, 2024

Does this still occur with the new release? If so, could you attach a recording of it by any chance?

@baselshlewett
Copy link
Author

baselshlewett commented Jan 2, 2024

Hey @nitzanwix, thanks for your efforts,

On android, autoplay and loop are working as expected.

However, the initial starting position is set to the last index of the carousel. (I tried settings the initialPage prop to 0, but it doesn't work unless it's through a hot-reload)

On iOS the only issue is that initial issue of this bug report, which is the jumping between indexes.

See attached: (left is iOS, right is Android)
Video screen recording of jumping carousel:
https://github.com/wix/react-native-ui-lib/assets/20260587/b2a2a5e5-ebea-46b8-9260-bb6b77642495

Screenshot of initial page wrong index on android:
Screenshot 2024-01-02 at 11 38 00

@baselshlewett
Copy link
Author

@nitzanwix any updates?

@fmtjava
Copy link

fmtjava commented May 7, 2024

This issue still exists on the Android platform, currently using React Native version: 0.73.0 and React Native UI Lib version: 7.21.2

@mdecrocemovson
Copy link

also experiencing strange carousel behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in one of the components
Projects
Status: To do
Development

No branches or pull requests

4 participants