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
218 stars 80 forks source link

Unable to set First tab (0 index tab) by default? #409

Open anarnoli opened 2 years ago

anarnoli commented 2 years ago

I am using MDTabs component and unable to set first tab by default when page loads

There is a property called selectedIndex in which if I set 0 then it throws ERROR TypeError: Cannot read property 'addObserverForKeyPathOptionsContext' of undefined

So I have to set 1 always which selects 2nd tab be default. Please suggest how to achieve it.

Does it make any impact if using <MDTabs> inside <BottomNavigationBar>?

<MDTabs selectedIndex="1" tabsPosition="top" swipeEnabled="false">
    <MDTabStrip>
        <MDTabStripItem>
            <Label text="Tab A"></Label>
            <Image src="font://&#xf0f0;" class="fas"></Image>
        </MDTabStripItem>
        <MDTabStripItem>
            <Label text="Tab B"></Label>
            <Image src="font://&#xf234;" class="fas"></Image>
        </MDTabStripItem>
    </MDTabStrip>

    <MDTabContentItem>
           <Label text="Tab A Details" class="h2 text-center"></Label>
    </MDTabContentItem>
    <MDTabContentItem>
        <GridLayout>
            <Label text="Tab B Details" class="h2 text-center"></Label>
        </GridLayout>
    </MDTabContentItem>
  </MDTabs>
farfromrefug commented 2 years ago

@anarnoli please share the full error stack