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

TabMenu error when no route matches one of the menu paths #416

Closed
Dravere opened this issue Aug 1, 2020 · 0 comments
Closed

TabMenu error when no route matches one of the menu paths #416

Dravere opened this issue Aug 1, 2020 · 0 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Dravere
Copy link

Dravere commented Aug 1, 2020

The TabMenu creates a JavaScript warning in the dev console when no path matches any of the provided to paths in the menu items. The error happens in updateInkBar in DomHandler.getWidth because the passed tabHeader/el parameter is undefined.

this.$refs.inkbar.style.width = DomHandler.getWidth(tabHeader) + 'px';

The parameter is undefined because findActiveTabIndex on the line before returned null, since no active route could be found.

I would recommend to at least catch the null value in there and do something like this:

updateInkBar() {
    let activeTabIndex = this.findActiveTabIndex();
    if (activeTabIndex !== null) {
        let tabHeader = this.$refs.nav.children[activeTabIndex];
        this.$refs.inkbar.style.width = DomHandler.getWidth(tabHeader) + 'px';
        this.$refs.inkbar.style.left =  DomHandler.getOffset(tabHeader).left - DomHandler.getOffset(this.$refs.nav).left + 'px';
    } else {
        this.$refs.inkbar.style.width = '0px';
        this.$refs.inkbar.style.left =  '0px';
    }
}
@cagataycivici cagataycivici self-assigned this Aug 4, 2020
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Aug 4, 2020
@cagataycivici cagataycivici added this to the 2.0.6 milestone Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants