react-router-bootstrap icon indicating copy to clipboard operation
react-router-bootstrap copied to clipboard

NavDropdown active state

Open javorka opened this issue 10 years ago • 1 comments

I have something like this in my component:

<Nav pullRight>
    <NavDropdown eventKey={1} title={userDropdownTitle} id="user-dropdown">
        <LinkContainer to="/sign-in">
            <MenuItem eventKey={1.1}><i className="fa fa-sign-in" /> Sign in</MenuItem>
        </LinkContainer>
        <LinkContainer to="/sign-out">
            <MenuItem eventKey={1.2}><i className="fa fa-sign-out" /> Sign out</MenuItem>
        </LinkContainer>
        <LinkContainer to="/user-settings">
            <MenuItem eventKey={1.3}><i className="fa fa-cog" /> Settings</MenuItem>
        </LinkContainer>
    </NavDropdown>
</Nav>

and router like this:

<Router history={history}>
    <Route path="/" component={Main}>
        <IndexRoute component={Dashboard} />
        <Route path="/sign-in" component={Tool} />
        <Route path="/sign-out" component={Tool} />
        <Route path="/user-settings" component={Tool} />
    </Route>
</Router>

When I have active a MenuItem "sign-in", NavDropdown is not active.

javorka avatar Oct 29 '16 23:10 javorka

You'll need to compute active status yourself in this case. NavDropdown doesn't explicitly know what its children are, and there isn't really a good way to make it handle this case without too much tight coupling.

taion avatar Oct 30 '16 18:10 taion