[Sidebar] doesn’t close on mobile when a hamburger button is tapped
The issue you can see in this template, when viewing in mobile pressing the three bars (sidebar icon) to open sidebar, and then again pressing those same three bars (sidebar icon) to close sidebar, it does not close. It closes after you press again those three bars (sidebar icon). I did reproduce this issue with chrome and my android phone.
In template, 2.2.4 version is used, so I switched to 2.2.10, but same result.
I set debug to true, and this is what happens when you try to close sidebar, but it does not close

Hi @ciajulius, I didn’t quite understand the issue, it closes only the second time you press the sidebar icon, but not the first? Did you reproduce it on the desktop version of Chrome, or on Chrome for Android? What version of Chrome/Android were you using?
I'm using android 6.0.1, and chrome version is 57.0.2987.132 When in that template I tap on sidebar icon to open sidebar, it opens, when for the second time I tap sidebar icon to close it, it does not close (in previous screenshot you can see what happened on that tap when it did not close (it tried to close and immediately opened up again)). When I tap again on sidebar icon - sidebar closes. If I would tap somewhere else, not on sidebar icon, sidebar would close as expected (from the first time).
To reproduce:
- Open chrome browser on your computer
- Go here
- Open Developer tools
- Click "toggle device toolbar" and select device that's screen width is less than 700px
- Tap on sidebar icon (this will open sidebar)
- Tap on sidebar icon (in my case, this does not close sidebar)
@ciajulius got it, thank you.
For the future reference, if you can’t see it, repeat it a couple of times.
@Banandrew if this is not a bug, what was done incorrectly that lead to this issue?
@ciajulius I don’t know, I just thought that I labeled it prematurely. I use a VM for development, and when I ran the example in my local environment, I couldn’t reproduce the issue: http://i.imgur.com/J8eGWVP.gifv I can do this indefinitely, and it won’t show up, but I do see it on SUI’s website—it closes and opens the sidebar almost immediately every fifth click or so.
Have you tried replicating the example locally?
@Banandrew no, I didn't. I use minified files from cdn, since I'm kinda new to semantic ui, I used the same template as the one with the issue, that's how I found this issue today. Tried a few different versions of semantic, did not help.
I just checked SUI's doc's with my android phone, sidebar examples page, in one of examples I can reproduce this issue. Example that I'm talking about, has title "Triggering show/hide with other content", I pressed "run code", and tapping on "trigger sidebar" button makes sidebar misbehave the same way, but as you noticed before, this happens not every time the button is being pressed
@ciajulius I sat down to figure it out, so what happens is the button that triggers the sidebar is clickable when the sidebar is being shown, and when you click anywhere outside of the sidebar it closes, but since the button is also clickable, the sidebar opens immediately after being closed.
This behaviour is intended, and it’s a developer’s responsibility to address clickable elements. If you’ll have questions in the future, you can always ask them in our Gitter chatroom.
@Banandrew Well, I still think this is a bug. Why doesn't this happen every time then? Why doesn't this happen when I'm using laptop without chrome developer tools? Attach events defaults to toggle, so it should open when given element is pressed, and close when given element is pressed again. One action at a time, but not both. And seems like I am not the first person who runs into this problem: https://github.com/Semantic-Org/Semantic-UI/issues/3285 https://github.com/Semantic-Org/Semantic-UI/issues/1683
@ciajulius You’re right, sorry about that.
I have same issue, the sidebar('hide') behavior is not working on iOS devices, tested on version 2.2.9
I had the same issue on a page of mine mobile devices. It worked when I explicitly called sidebar('hide') e.g.
$sidebar.find('a.item').click(function(){
$sidebar.sidebar('hide');
});
#3285 #1683 should be marked as duplicates.
There has been no activity in this thread for 90 days. While we care about every issue and we’d love to see this fixed, the core team’s time is limited so we have to focus our attention on the issues that are most pressing. Therefore, we will likely not be able to get to this one.
However, PRs for this issue will of course be accepted and welcome!
If there is no more activity in the next 90 days, this issue will be closed automatically for housekeeping. To prevent this, simply leave a reply here. Thanks!
I faced the exact same issue, for me it happened on all mobile devices and tablets, however to fix it, i used the callback functions to set up a local boolean var in my js. I am using the latest version of semantic-ui.
The open is the boolean variable that indicated the status of the sidebar, and this worked perfectly! (sidebar is just the function i had since i was using it too many times).
open ? sidebar('show') : sidebar('hide');
Although, I do think this is a bug and beats the purpose of having a toggle if hacks like this are needed.
Any update on this? I would call this a bug as well. If default behavior is toggle then it should toggle!
I have same issue in version 2.4.1