-
Notifications
You must be signed in to change notification settings - Fork 254
Somehow header tabs are not working correctly #66
Comments
Could you provide reduced test case for that? |
Probably something related with your code with React-router, but if you can share some code, we might be able to help you :) |
I'm working on one as we speak! |
There we go, example repo: https://github.com/janpieterz/Mdl-header-tabs And I think by creating it all over again I've almost answered my own question, but I'm not a 100% sure. In my official app I use the browser history instead of a hashhistory, but since I serve it off the file system (and browser don't allow histories to be replaced), I use hashhistory, shouldn't make a big difference for this, certainly because the same behavior occurs. When I have the Tabs right away on the home page, it works fine. My current line of thinking is that those Tabs should only be 'made' there when the tab-panels are there, which makes sense. But since in the source of the header tabs there is no component upgrade call towards MDL since the whole layout upgrade seems to happen in layout.js and not the individual component like HeaderTabs. Obviously I'm not going to use the tabs like this in the 'real' application. They'll be added dynamically per page. I had that before as well, but that didn't work either so I reverted to a more hardcoded one, which might bring this problem. Any thoughts on dynamically adding tabs in the header? It seems like as soon as I load the page directly on the items component it works fine, but as soon as I come from another part it isn't (which is what would happen if those headers are dynamically added, since the layout is already upgraded). Calling the upgrade again in the console doesn't seem to solve it. I know this is mostly my 'mess' but I'm curious how to tackle this one, any help would be massively appreciated. |
I've been trying, in the example, to get the tabs to be dynamically populated, only way I can see that quickly happening is adding a Flux store like Alt. In case this is handy, anyone an idea to do it simpler? EDIT: I'm doing that in the real app since that one is all setup for this. |
Alright, I think I've found ít, although I'm not sure about a decent solution: |
I have it 'working' now, by using a relatively dirty hack provided here: For future reference:
The HeaderTabs of react-mdl needs to be in the DOM already for this to work. I'll leave it open so we can discuss the above possibility, if not feasible/possible/wanted it can be closed! Thanks for the little push that send me down the drain of issues @ MDL and gave me the solution ;) More references I found about this: |
I'm not sure about real issue, but first issue that I see is that tabs' href in |
Yeah, that's what happened when I just insert them hard in the header. Second page it does work, but not correctly, although the fix above makes the dynamic ones working, there's just a manual extra step needed to initialize the tabs if the layout is not rendered again. Jan-Pieter Zoutewelle
|
Several things here:
I'll put the Tabs in header at the top of my todo :) |
This might not be an error perse with react-mdl, but I'm unsure where else it would lie as off now.
I've got a couple of components, one is a header and the other one is a specific page.
The header component renders the MDL header tabs components. These work well and seem to be initialized ok (since if you don't they look different).
Then the page content has the tab panels in them.
What happens is that it actually does work, but it does not de-activate the other tabs. So effectively if you switch tabs, it only shows new tabs and keeps the other tabs content also rendered (the .is-active class stays on them).
I'm using React-Router and besides that there's not a lot of things that I think might have any relevance.
If I copy and paste the 'default' example made by mdl it works fine.
Any thoughts?
EDIT:
An image showing it happened in real life. After pressing all tabs this is shown. The content per tab is literally Tab x, and obviously in the image Tab 1- Tab 5 should not be visible there.
It does however 'enable' the tabs, so on first visit withouth pressing any tab button it looks like:
The text was updated successfully, but these errors were encountered: