nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
219 stars 80 forks source link

BottomNvigationBar : Tabpressed not fired on the first Item with Vue+NS+Android #384

Open Echoju opened 2 years ago

Echoju commented 2 years ago

Hello,

I use BottomNavigationBar with Vue.js. I set isSelectable to False to each item so that I can use the TabPressed event, the problem I found is that this event is not fired on the first item only (the two others work fine!) :

 <MDBottomNavigationBar id="id_tab_nav" ref="my_tab_navigation_bottom" backgroundColor="#70152b" activeColor="#FFF" inactiveColor="#FFF" row="1"  @tabPressed="tabPressedEvent"    > 

        <MDBottomNavigationTab color="#FFF" title="Home" icon="res://home" attr-link="Home"  
        isSelectable="false"   />

        <MDBottomNavigationTab color="#FFF" title="Search" icon="res://search" attr-link="Search" 
        isSelectable="false"   />

        <MDBottomNavigationTab color="#FFF" title="User"  icon="res://user" attr-link="Login" 
        isSelectable="false"    /> 

    </MDBottomNavigationBar>
Here is my function for the tabPressed event : 
        tabPressedEvent(e)
    {
         console.log('element=>refs',this.itemTabNavView.items);

         console.log('navigateTo Item =>');
         console.log(e.index);  
        this.$navigateTo(this.items_navs[e.index]);   

    }
Is there any solution to solve this problem ?
Thanks.
farfromrefug commented 2 years ago

tabPressed is not emited if the tabs are not selectable

Echoju commented 2 years ago

that's not how it is explained in the docs => " Function fired every time the user tap a tab with isSelectable: false "

Anyway, I think I found the reason : I think that the bottomTab select by default the first item then as long as it is selected the press event can't be fired.

farfromrefug commented 2 years ago

@Echoju thanks for.pointing that out. if you can create a PR if you find the fix that would be awesome!