Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab navigation for external links is still broken (#1028 #929) #4072

Closed
kroegerama opened this issue Feb 3, 2016 · 5 comments
Closed

Tab navigation for external links is still broken (#1028 #929) #4072

kroegerama opened this issue Feb 3, 2016 · 5 comments

Comments

@kroegerama
Copy link

Issues #1028 and #929 still seem to be not properly solved in V1.1.1.
The code seems a little weird. You are adding the EventListener twice. Maybe a merge conflict?

layout.js, line 502:

function MaterialLayoutTab(tab, tabs, panels, layout) {
    /**
     * Auxiliary method to programmatically select a tab in the UI.
     */
    function selectTab() {
        var href = tab.href.split('#')[1];
        var panel = layout.content_.querySelector('#' + href);
        layout.resetTabState_(tabs);
        layout.resetPanelState_(panels);
        tab.classList.add(layout.CssClasses_.IS_ACTIVE);
        panel.classList.add(layout.CssClasses_.IS_ACTIVE);
    }
    if (layout.tabBar_.classList.contains(layout.CssClasses_.JS_RIPPLE_EFFECT)) {
        var rippleContainer = document.createElement('span');
        rippleContainer.classList.add(layout.CssClasses_.RIPPLE_CONTAINER);
        rippleContainer.classList.add(layout.CssClasses_.JS_RIPPLE_EFFECT);
        var ripple = document.createElement('span');
        ripple.classList.add(layout.CssClasses_.RIPPLE);
        rippleContainer.appendChild(ripple);
        tab.appendChild(rippleContainer);
    }
    tab.addEventListener('click', function (e) {
        if (tab.getAttribute('href').charAt(0) === '#') {
            e.preventDefault();
            selectTab();
        }
    });
    tab.show = selectTab;
    tab.addEventListener('click', function (e) {
        e.preventDefault();
        var href = tab.href.split('#')[1];
        var panel = layout.content_.querySelector('#' + href);
        layout.resetTabState_(tabs);
        layout.resetPanelState_(panels);
        tab.classList.add(layout.CssClasses_.IS_ACTIVE);
        panel.classList.add(layout.CssClasses_.IS_ACTIVE);
    });
}

Furthermore, tabs.js, line 130 seems missing the === '#' check.

@VamosErik88
Copy link

Any news on this argument? I'm really looking forward for this to be implemented in MDL.

compressed added a commit to BeetLife/material-design-lite that referenced this issue Apr 11, 2016
@ross-nordstrom
Copy link

ross-nordstrom commented May 9, 2016

It was still broken for me as of v1.1.3 - #4183 (comment), but is easily fixed

@VamosErik88
Copy link

@ross-nordstrom how did you fix it? I'd be glad to implement this feature on my project.

@ross-nordstrom
Copy link

**Easy to fix within the MDL code. I haven't found a workaround yet...

See the commit @compressed referenced higher up in this thread for how to fix -- basically we just need an if wrapping the tab-clicking logic.

@VamosErik88
Copy link

Oh ok got it...
Hope they fix it ASAP ;)

MitchLillie added a commit to MitchLillie/material-design-lite that referenced this issue Oct 19, 2016
* Check for '#' before proceeding with querySelector and tab state modification
* Allows anchors to point to other links

Closes google#4072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants