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

[Sidebar] Changes directions if called twice #2644

Closed
pareeohnos opened this issue Jul 15, 2015 · 6 comments
Closed

[Sidebar] Changes directions if called twice #2644

pareeohnos opened this issue Jul 15, 2015 · 6 comments
Milestone

Comments

@pareeohnos
Copy link

I'm having a strange issue with sidebars. My page has two sidebars, one on the left and one on the right. The structure of my code means the sidebar function is called twice, once to initialise it, and once to attach an event to a button that will make it visible when in a mobile view:

$('.primary.sidebar').sidebar({ transition: 'slide along' });
$('.secondary.sidebar').first()
    .sidebar('attach events', '#navigation .item.show-resource-sidebar', 'toggle');

Fairly standard, and more or less how the documentation shows how to do it (without the first step though?)

My two sidebars are defined in the HTML as so (sorry, using HAML):

.ui.left.vertical.primary.sidebar
.ui.right.vertical.secondary.resource.sidebar

The primary sidebar is working as expected, however the secondary sidebar is behaving unusually. The initial sidebar call works fine, but when the second call to attach events is run, the sidebar moves and becomes a left sidebar. Semantic-UI is changing the class from right to left without me requesting it.

I've tried to replicate in a fiddle, and had partial success. I can't replicate it when my second call is to attach an event, it seems to work as expected, however if I ignore that and make two calls to the initialise itself, it is reproducing it.

https://jsfiddle.net/9hn5fw8w/1/

The second call to dropdown is commented out, and as you'll see it works correctly. But if you uncomment the second call, the sidebar is moved to the left of the screen.

@pareeohnos
Copy link
Author

Slight update. I realised that my code was slightly bugged in terms of the order in which the code was running. The attach events call was occurring before the initialisation call. Here is a new fiddle replicating it now.

https://jsfiddle.net/wLukcamc/1/

@jlukic
Copy link
Member

jlukic commented Jul 15, 2015

http://jsfiddle.net/pe8gv405/

If you use a different animation like overlay you need to specify the animation in JS as well. Appears to be working fine.

@pareeohnos
Copy link
Author

I'm still seeing the issue, even specifying the transition in JS.
See these examples:

http://jsfiddle.net/o4w62q58/1/
http://jsfiddle.net/nsjzg2ts/1/

The first example is simply calling the sidebar initialiser twice. Both calls are explicitly specifying the transition effect, yet it is still being moved to the wrong side.

The second example is what was actually happening in my code due to the script order, but nevertheless still highlight the issue. The first call is attaching the events, and the second call is initialising it, which is again moving it the wrong side even with the transition specified

@jlukic
Copy link
Member

jlukic commented Jul 17, 2015

Might not be necessary, I'll need to review the git commit history for why
https://github.com/Semantic-Org/Semantic-UI/blob/master/src/definitions/modules/sidebar.js#L123

@pareeohnos
Copy link
Author

I guess it's not really a major issue. My issue was resolved by just having the code execute in the correct order. And I guess people shouldn't be attempting to initialise it twice, but it is slightly unexpected behaviour. No major reason to change though.

@jlukic
Copy link
Member

jlukic commented Jul 17, 2015

It seems safe to remove and will reduce user headaches.

@jlukic jlukic changed the title Sidebar changes directions if called twice [Sidebar] Changes directions if called twice Jul 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants