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

OBKN-658 OrderDetails returns to first picklist item on every pick #264

Merged
merged 1 commit into from
Jul 12, 2022

Conversation

kchelstowski
Copy link
Collaborator

The ticket describes something else than Justin's videos, but that's okay and I'll describe why:

  • when Justin was recording those movies, he was using version before the refactor of OrderDetails component and that was a big issue connected to Carousel and FlatList: a nice discussion about this topic is here: link
    To fix that (it seemed like for all people reporting that issue, the problem happened when their data was > 6 length) I just had to add useScrollview={true}.

BUT it was when using old, before refactor OrderDetails component. On new one it's true, that it always returned to first item, because initialPicklistItemIndex was passed to props wrongly and it was always 0 when console.loged inside Carousel (it was setting the intialPicklsitItemIndex state as the previous one, so in general it was setting that as the initial value, so 0).
Then another problem saw the light of the day - when I fixed initialPicklistItemIndex it turned out, that the Carousel 'doesn't see' that the state (initialPiclistItemIndex) updated, so in the beginning it was rendered a few times with 0 passed as props (before the getOrderDetails() function ended its work) and then it was passing the correct value, for example: 8 (but those renders were just a characteristic of React and there is nothing wrong about that - the wrong part was that the Carousel didn't react that firstItem was updated from 0 to 8 etc.).
I was wondering why and thought that maybe Carousel just doesn't re-render after the firstItem changes and yeah, the key was set (don't know why) as 3. I think it made Carousel not re-rendering when the firstItem changed from props.
After changing key to actual value of initialPicklistItemIndex the problem doesn't happen anymore - the Carousel updates the firstItem propely (it just re-renders)

@kchelstowski kchelstowski requested a review from awalkowiak July 12, 2022 07:54
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@awalkowiak awalkowiak merged commit 21aa219 into develop Jul 12, 2022
@awalkowiak awalkowiak deleted the OBKN-658 branch July 12, 2022 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants