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(android): Fix setting an active tab for TabGroup before opening. #10740
Conversation
Fixes setting an active tab for TabGroup before it is opened. Fixes backwards compatiblity for events. Removes unused code. Clean up imports. Adds new unit tests. Updates docs. Fixes TIMOB-26843
|
@@ -445,14 +445,10 @@ protected void handlePostOpen() | |||
|
|||
TabProxy activeTab = handleGetActiveTab(); | |||
if (activeTab != null) { | |||
selectedTab = activeTab; | |||
selectedTab = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class' onTabSelected()
method is missing a null
check on the selectedTab
member variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to this onTabSelected()
method?
https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/TabGroupProxy.java#L529
If that is the case, it is intended for the selectedTab
to be null in order to skip the sending of the focus/blur
events when a tab is set as an active one before the opening of the TabGroup. But I may have not got what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you're right. Never mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the unit test around blur events is now failing, and is likely related to the changes in this area...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some digging I found that the "blur" unit test started failing because this PR fixed firing a pair of focus/blur
events that are not supposed to be fired. That problem was introduced at the same time when the unit test was added (Both by me) and this is the reason it didn't fail every single time in other PRs. With my latest update this should be cleared up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit test is passing now.
.getTabList() | ||
.get(currentlySelectedIndex) | ||
.fireEvent(TiC.EVENT_UNSELECTED, null, false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if getProxy()
returns null
in the selectTabItemInController()
method and the onMenuItemClick()
method, which can happen when the proxy has been released (ie: it's JavaScript object was garbage collected).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Looks good @ypbnv. I'm just asking for a few more |
FR Passed. Active tab works fine .some tests are failed in Jenkins.waiting for that to get resolved. also we need Backport PR FOR 8.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Pass
@jquick-axway Would you be able to take a look at my latest commit - I moved the nullifying of a Tab's parent - from when the views are released to when the Tab proxy itself is released. That is the reason the |
JIRA: https://jira.appcelerator.org/browse/TIMOB-26843
Description:
Fixes setting an active tab for TabGroup before it is opened. Fixes backwards compatibility for
events - one unnecessary "focus" is currently triggered on TabGroup opening. Removes unused code. Clean up imports. Adds new unit tests. Updates docs.
Note: I have tested with both supported styles - default and bottom navigation. What I wonder is what is the best way to include the bottom navigation style in unit tests - add all the tests with it ( that would work, but for any new style possibly added later it may become too much work) or we use the style property randomly chosen for each test. With the latter we still may miss some edge cases.
I will try to figure out the failing of the "blur" unit tests since this PR changes event firing a little bit.
Test case:
app.js