Open vedtam opened 5 years ago
Reproduction with vanilla MDC Web: https://glitch.com/edit/#!/mdc-web-4214
We're only ever instantiating tabs based on the DOM during initialize
. We would probably need to add an explicit addTab
(and removeTab
?) API that would receive an mdc-tab
element (or possibly an index for removal), or something like reinstantiateTabs
that would destroy all current tab instances and reinstantiate based on the current state of the DOM.
@kfranqueiro thanks for the clarification. Well as a workaround, I moved the 'static' tab inside the loop that generates the rest of the tabs after data gets fetched, now all tabs render simultaneously but I can see other cases where this wouldn't be an option so having an add/remove Tab
or reinstantiateTabs
method would be nice.
I think you might forget to import those files
import {MDCTabBar} from '@material/tab-bar'; const tabBar = new MDCTabBar(document.querySelector('.mdc-tab-bar'));
Is there any update on this.
It seems a lot of the mdc controls require that the data be statically passed to any implementation. It makes the controls rather unsuitable to use.
To work around this, I had to catch my tab-item render event, and hack the MDC tab into the tabList of the tabAdapter.
On top of this, there seems to be a global tracking of these tab items, so each tab-item must have a unique id globally.
const anyTabBar = this.TabBar as any;
anyTabBar.tabList.push(Tab);
const randomId = Math.round(Math.random() * Number.MAX_VALUE);
const id = `mdc-tab-${ randomId }`;
Tab.id = id;
Tab.root.id = id;
I am also interested in some kind of add/remove Tab
or reinstantiateTabs
solution.
Hi guys,
In my element I'm displaying category titles as Tabs. The problem is that I can't switch between tabs which are rendered after the categories get fetched:
I've created a demo on glitch that demonstrates the issue, you can see the source here.
I've tried to look for answers on discord, but I got no proper answer there. Thanks!