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

Fix Apple TV TabBarIOS issue (#15081) #15093

Closed
wants to merge 5 commits into from

Conversation

douglowder
Copy link
Contributor

Motivation

Fix flickering in TabBarIOS on Apple TV... issue #15081

Test plan

Existing CI should still pass. Issue is resolved when testing the example code in #15081 .

@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. GH Review: review-needed labels Jul 19, 2017
@@ -175,6 +175,18 @@ - (void)setItemPositioning:(UITabBarItemPositioning)itemPositioning

#pragma mark - UITabBarControllerDelegate

#if TARGET_OS_TV

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(nonnull UIViewController *)viewController
Copy link
Contributor Author

Choose a reason for hiding this comment

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

didSelectViewController seems to work fine on iOS too... if desired, we could just use this method for both iOS and tvOS.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I'd prefer that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@facebook facebook deleted a comment from pull-bot Jul 19, 2017
@hramos
Copy link
Contributor

hramos commented Jul 19, 2017

Removed unrelated Danger warning.

@javache
Copy link
Member

javache commented Jul 19, 2017

Hmm, this may cause subtle differences. It seems like before we actually rejected all calls to shouldSelectViewController, and then the JS side would actually set the tabbar item it wanted, but in the new model, we would always switch tabs, no longer leaving JS a choice.

@douglowder
Copy link
Contributor Author

Wow... so JS could actually select a different tab from the one the user picked? Interesting!

Since tvOS tab bar works very differently, I'd suggest that we go back to my original commit that just fixes tvOS and leaves iOS behavior unchanged.

@javache
Copy link
Member

javache commented Jul 19, 2017

Well the idea is that TabBarItemIOS is a controlled component: all state changes need to come from JS and not from native. I'm not sure why this doesn't work correctly on tvOS.

@douglowder
Copy link
Contributor Author

In tvOS testing, I find that the way the tab bar works is very different. If you use the TV remote to navigate from one tab bar item to the next, the new tab bar item is highlighted BEFORE shouldSelectViewController: is called. So there's no way to avoid changing the state of the tab bar prior to JS being called. For this reason, I think using didSelectViewController: is better for tvOS.

@douglowder douglowder requested a review from shergin as a code owner July 19, 2017 20:56
@javache
Copy link
Member

javache commented Jul 19, 2017

Ok, makes sense. It does mean it's possible for JS state and native state to go out of sync though. One way classes like RCTTextView solve this is by accepting the native state change, and having the JS side immediately call setNativeProps with the desired state (even if it's the same as the old one).

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Jul 20, 2017
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Jul 20, 2017
@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jul 21, 2017
@facebook-github-bot
Copy link
Contributor

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

@facebook facebook deleted a comment from pull-bot Jul 21, 2017
@facebook-github-bot
Copy link
Contributor

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

@douglowder
Copy link
Contributor Author

Did additional testing of the issue... this patch is part of the solution, but some additional changes are needed. Closing this, and will submit the complete fix later.

@douglowder douglowder closed this Jul 23, 2017
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. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants