ui-material-components
ui-material-components copied to clipboard
tabselected event is fired when tab is selected programmatically on Android
If the demo apps cannot help and there is no issue for your problem, tell us about it
If I change the current page with a way other than the bottom navigation, I select to related to bottom bar tab to match it with current page. On iOS, this works without problem. However, on Android, calling selectTab() function triggers selectedTab event.
Which platform(s) does your issue occur on?
- Android only
- Android version: 6.2.0
- Emulator
Please, provide the following version numbers that your issue occurs with:
- CLI: 6.2.2
- Cross-platform modules: 6.1.2
- Runtime(s): 6.2.0 for both
- Plugin(s): 2.5.4 for bottomnavigationbar
@erkanarslan i actually find it normal for event to be triggered. I would prefer for it to trigger both on iOS and Android. Would that be ok with you?
The problem is I listen to selectedTab event and navigate to related page based on that event. However, bottom navigation is not the only place a user can navigate to another page. For example, they can use buttons in a page or simply back button of iOS (software) and Android (hardware). In this case, I have to update which tab is selected (selectTab) so that bottom navigation won't highlight the incorrect tab. However, if tab-select event is fired when a tab is selected programmatically, this will trigger a second navigation. You see, navigation updates the selected tab, and that triggers the navigation again. I think calling the selectTab function should not create an event, or the event object should have a flag indicating whether the event is triggered by a tap or programmatically by my code.
For anyone facing the same issue:
You can set a lock variable to true before calling selectTab() programmatically. Then in your event listener for tab-selected you can check if that variable is set to true, then don't navigate.
Remember to set it back to false after calling selectTab().