fix: onChangeTab called twice on Android#1093
Merged
ptomasroos merged 1 commit intoptomasroos:masterfrom Jul 24, 2020
Merged
Conversation
`onPageSelected={this._updateSelectedPage}` ViewPager prop causes onTabChange to be called twice when change tabs without any gesture actions
this will fix duplicated tab updates on android
#### when user clicked tab buttons
`goToPage -> updateSceneKeys(onTabChange) -> Screen Update -> onPageSelected={_updateSelectedPage} -> updateSceneKeys(onTabChange) -> Screen Update`
#### when user swiped tab views
`Swipe -> onPageSelected={_updateSelectedPage} -> updateSceneKeys(onTabChange) -> Screen Update`
#### when user clicked tab buttons with this patch
`goToPage -> set tabWillChangeWithoutGesture -> updateSceneKeys(onTabChange) -> Screen Update -> onPageSelected={_updateSelectedPage} -> ignore updateSceneKeys(onTabChange) -> remove tabWillChangeWithoutGesture`
Owner
|
Thanks for working on this! |
Contributor
Author
|
@ptomasroos Could you merge it? Please let me know if you need anything else. :) |
|
@ptomasroos can you release a new version that includes the commits of this PR and a couple of others already merged in master? thanks |
TimMun
pushed a commit
to TimMun/react-native-scrollable-tab-view
that referenced
this pull request
Sep 11, 2021
`onPageSelected={this._updateSelectedPage}` ViewPager prop causes onTabChange to be called twice when change tabs without any gesture actions
this will fix duplicated tab updates on android
#### when user clicked tab buttons
`goToPage -> updateSceneKeys(onTabChange) -> Screen Update -> onPageSelected={_updateSelectedPage} -> updateSceneKeys(onTabChange) -> Screen Update`
#### when user swiped tab views
`Swipe -> onPageSelected={_updateSelectedPage} -> updateSceneKeys(onTabChange) -> Screen Update`
#### when user clicked tab buttons with this patch
`goToPage -> set tabWillChangeWithoutGesture -> updateSceneKeys(onTabChange) -> Screen Update -> onPageSelected={_updateSelectedPage} -> ignore updateSceneKeys(onTabChange) -> remove tabWillChangeWithoutGesture`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This will fix duplicated tab updates on android (resolve #1060)
onPageSelected={this._updateSelectedPage}ViewPager prop causes onChangeTab to be called twice when change tabs without any gesture actions(I used onChangeTab with double click a tab for reset scroll-offset in tab-view or reset tab-index in nested tab-views)
[Before] When user clicked tab buttons
goToPageupdateSceneKeysandonChangeTab(index 0,1)onPageSelected={_updateSelectedPage}updateSceneKeysandonChangeTab(index 1,1)[After] When user clicked tab buttons
goToPageupdateSceneKeysandonChangeTab(index 0,1)[Before & After] When user swiped tab views
onPageSelected={_updateSelectedPage}updateSceneKeysandonChangeTab(index 0,1)