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

Fix sidebar collapse regression #1409

Merged
merged 3 commits into from Nov 18, 2018
Merged

Conversation

atrol
Copy link
Member

@atrol atrol commented Nov 14, 2018

Regression introduced in version 2.13.0 commit b7b9145

Fixes #24976

@atrol atrol self-assigned this Nov 14, 2018
Copy link
Member

@dregad dregad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is not appropriate, as it reverts the original commit, and therefore reintroduces the duplicate HTML element ID that was removed as part of PR #1297.

I don't have time right now to test if that would actually work in all cases, but I believe that changing the other sidebar div's ID (see layout_sidebar_begin() function above) would be sufficient to both fix the regression and avoid duplicate IDs.

If not, the proper fix will be more complex, likely requiring changes at javascript level.

@atrol
Copy link
Member Author

atrol commented Nov 15, 2018

I could also remove the id in layout_sidebar_begin(), or @dregad do you prefer introducing a new id, something like sidebar-begin ?

@dregad
Copy link
Member

dregad commented Nov 15, 2018

It might work too, I didn't test. I'm fine either way (as long as it works 😉) but it may indeed be better not to have an ID if it's not being used.

@atrol
Copy link
Member Author

atrol commented Nov 15, 2018

It might work too

Removing the ID works at first sight, updated the PR.
Will do some more tests on different browsers.

@atrol
Copy link
Member Author

atrol commented Nov 15, 2018

Did some more tests.
The latest change (remove the ID in layout_sidebar_begin() seems to work quite good at first sight, but introduces another regression.
The burger menu that is used if horizontal size is small, does not work any longer.
As this is not acceptable (especially on mobile devices in portrait mode), I will change back to my first change.

Of course, it will reintroduce the duplicate HTML element ID, but it seems to work (tested on various desktop browsers and various window sizes, no mobile tests).

Sorry @dregad I can't invest time for a clean solution.

@dregad
Copy link
Member

dregad commented Nov 16, 2018

The problem with duplicated ID is that it is impossible to reliably predict which element will be selected e.g. when using #sidebar in CSS. So while this may work today, there is no guarantee that it does in all browsers or will do in the future.

The erratic behavior you noticed during testing is a direct consequence of that - some parts of the code expect to reference the "button" div (e.g. common.js), while others are targetting the actual sidebar div.

The bug was introduced in 8a3eedc (when @syncguru added sidebar collapse state persistence), and is a mix of referencing the wrong element (since they share the same ID) and inconsistent logic to retrieve the sidebar div's name to store it in the cookie.

I'll push a commit with what I believe is the proper fix shortly. As far as I can tell, the regression is gone and the narrow screen issue with the burger menu is not present,

Copy link
Member Author

@atrol atrol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dregad your fix looks good.
I tried different screen sizes on latest versions of Firefox, Chrome and Safari on MacOS, IE11 and Edge on Windows 10 and Chrome on Android.

Can't try latest iOS at the moment, but risk is low, so I will merge.

atrol and others added 3 commits November 18, 2018 14:22
Regression introduced in version 2.13.0 commit b7b9145
The initial attempt at fixing this issue [1] introduced a regression in
the persistence of the sidebar's collapse state.

Using a different ID for the toggle button or the sidebar div caused
other issues (e.g. malfunctioning hambuger menu on narrow screens, or
failure to save collapse state).

The root cause was a bug in the javascript code saving the sidebar's
state, which was referencing the toggle button's id instead of the
sidebar div's.

We now have ID 'sidebar' for the actual sidebar, and 'sidebar-btn' for
the toggle button, and the javascript has been modified accordingly.

Fixes #24976

[1]: commit b7b9145
- replace the old collapse state using a regex
- use a single reference to the sidebar div
- calculate collapse state instead of using if statement
@atrol atrol merged commit 14b9582 into mantisbt:master Nov 18, 2018
@atrol atrol deleted the 24976-sidebar-collapse branch November 18, 2018 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants