question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fixed menu inside a Sidebar pushable?

See original GitHub issue

I’ve been stuck here. Basically, I added a fixed menu inside a sidebar pushable like so:

Sidebar.js

<Sidebar.Pushable as={ Segment }>
    <Sidebar as={ Menu } animation="overlay" width='thin'
             visible={ app.sidebarVisibility } icon='labeled'
             vertical inverted>
        <Menu.Item onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }
                   as={ NavLink } exact to="/">
            Home
        </Menu.Item>
        <Menu.Item onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }
                   as={ NavLink } to="/menu">
            Menu
        </Menu.Item>
    </Sidebar>
    <Sidebar.Pusher onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }>
        <Container className="Main-container">
            <Segment basic>
                <NavBar app={ app } onToggleSidebar={ onToggleSidebar } />
                { children }
            </Segment>
        </Container>
    </Sidebar.Pusher>
</Sidebar.Pushable>

NavBar.js

<Menu borderless fixed="top">
    { app.device && app.device.type === 'mobile' &&
    <Menu.Item>
        <Button basic icon="sidebar"
                onClick={ () => ( !app.sidebarVisibility && onToggleSidebar() ) } />
    </Menu.Item>
    }
    <Menu.Item header>Krispy Kreme</Menu.Item>
    { app.device && app.device.type !== 'mobile' &&
    <Menu.Menu>
        <Menu.Item as={ NavLink } to="/" exact>Home</Menu.Item>
        <Menu.Item as={ NavLink } to="/menu">Menu</Menu.Item>
    </Menu.Menu>
    }
    <Menu.Menu position="right">
        <Menu.Item>
            <Button basic icon="cart" label={ <Label color="red"> { cartItems } </Label> } />
        </Menu.Item>
    </Menu.Menu>
</Menu>

EDIT:

I was able to fix it by using flex layouts.

Basically, I had to make the Segment component inside the Sidebar.Pusher use display: flex with flex-direction: column so I can lay the contents properly. Then I gave it two children, the NavBar and the Content. I gave Content a flex-grow: 1 property. Now The header stays on top. Here’s how it looks like now:

<Sidebar.Pusher onClick={ () => ( app.sidebarVisibility && onToggleSidebar() ) }>
    <Segment basic>
        <NavBar app={ app } onToggleSidebar={ onToggleSidebar } />
        <Content>
            { children }
        </Content>
    </Segment>
</Sidebar.Pusher>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
Shurlowcommented, Apr 12, 2018

@RhanCandia I am having the same issue but your solution isn’t working for me. Any chance you could post the full code, including css? Thanks!

1reaction
tiagowippelcommented, May 2, 2018

I was unable to use this solution too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create reveal push menu with fixed position sidebar
First, when we mouseover the reveal menu, it instantly toggles between the states, revealing the menu (in a smooth animation, thanks to css- ......
Read more >
Sidebar | Semantic UI
A sidebar hides additional content beside a page.
Read more >
How To Create a Side Navigation Menu - W3Schools
Add all page content inside this div if you want the side nav to push page ... Set the width of the side...
Read more >
How to use the semantic-ui-react.Sidebar.Pushable function in ...
To help you get started, we've selected a few semantic-ui-react.Sidebar.Pushable examples, based on popular ways it is used in public projects.
Read more >
Sidebar + Fixed Top Menu in Semantic-UI React-Reactjs
Sidebar & pusher --> <Sidebar.Pushable as={Segment}> <!-- Sidebar menu --> <Sidebar visible={this.state.visible} as={Menu} animation="push" width="thin" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found