It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Collapse Sidebar by default - Default Theme

Hi,

is there a way to collapse the sidebar by default. We're using the Default Theme.

5 answers

This is an old thread, but I may have a simple solution to contribute.

I needed something similar... the home page of a space is generally more carefully curated.
We wanted that homepage to have a nice layout and force the sidebar to be collapsed to allow as much real estate as possible regardless of what the user wants or has done before.

Other pages in the space, we don't care so much. We're happy for the default behavior and user preferences to take effect.

So I created a quick user macro that, when dropped on a page, causes the sidebar to collapse (but remain visible) every time the page is loaded or reloaded. 

## @noparams
<script type="text/javascript" >
   jQuery(document).ready(function() {
      if(jQuery('.ia-fixed-sidebar.collapsed').length == 0) {
         jQuery('.expand-collapse-trigger').click();
     };
   });
</script>

I suppose you could add that to the theme somewhere to have it work globally (inside html macro).

Hello!

Looks like it's work only in Google Chrome.

I have no issue with the above in firefox, ie11 and chrome. 

But, with our current version of confluence (5.9.9) this poses a problem because of the sidebar state is remembered for users from page to page.

And when visiting a page with the macro above, the user's preference is set,

So instead, I've started hiding the sidebar on certain page using a macro:

## @noparams
<script type="text/javascript" >
   jQuery(document).ready(function() {
      jQuery('.ia-fixed-sidebar').hide()
      jQuery('.aui-page-panel').css('margin-left','0px')
   });
</script>

Note that this will prevent space admins from accessing the space tools from this page since the space tools icon will also be hidden.

I also have no issues with this in chrome, firefox or ie11.

I use latest 5.10.4, may be it's a reason, but in any case - thank you a lot!

Hi Peter,

I have literally just started using Confluence (6.2) and the sidebar needs to be one of the first things to be modified. I can’t quite believe there is no option to do this OOTB, but after finding this, I thought that this is exactly what I was after, however I could not get this to work at all. I have tried adding the User Macro as originally posted (with all 4 option, just in case), and just dropping it on the home page of a space, but nothing happens. I assume I’m doing something wrong as newbie.

This site at some point started to not display code correctly apparently.

Make sure in your macro that you decode all the html encoding so the &lt; looks like < and &gt; looks like >

Trying to see if I can re-insert the code and not get encoded

## @noparams

<script type="text/javascript" >
   jQuery(document).ready(function() {
      if(jQuery('.ia-fixed-sidebar.collapsed').length == 0) {
         jQuery('.expand-collapse-trigger').click();
     };
   });
</script>

 

 Great thank Peter. That works great for Chrome, but like Alexander above, Firefox (54 on PC) doesn’t seem to work. Can’t try IE or Edge as they are broken in later Windows builds and cannot browse through an IPsec VPN tunnel. 

 

I've just tried in Firefox and saw that it didn't work too... appears to be a timing of when the script is triggered (i.e. the navigation bar doesn't yet exist when the macro is rendered and runs).

The following works in Firefox:

## @noparams

<script type="text/javascript" >
jQuery(document).ajaxComplete(function() { if(jQuery('.ia-fixed-sidebar.collapsed').length == 0 ) { jQuery('.expand-collapse-trigger').click();
}; }); </script>

This runs when all ajax calls are complete rather than as soon as the base document is loaded. 

Edited to add:

But it has the problem that is executes multiple times while the page is open (every time confluence makes a call to refresh content). So if the user attemps to expand the navigation, it will collapse it again almost immediately.

You would need to expand on that logic perhaps to prevent this.

Maybe something like:

## @noparams

<script type="text/javascript" >
   var runOnce = false;
   jQuery(document).ajaxComplete(function() {
      if(jQuery('.ia-fixed-sidebar.collapsed').length == 0 && runOnce == false) {
         jQuery('.expand-collapse-trigger').click();
         runOnce = true
     };
   });
</script>

Nice - I'm glad soemone know what they are doing - thanks very much

0 votes
Daryl Chuah Atlassian Team May 05, 2013

Hi Jum

Yes you can.

Here you go: https://confluence.atlassian.com/pages/viewpage.action?pageId=330796984

Hopefully it helps!

Cheers :)

Hi Daryl,

thanks for the answer. However, if I remove the code the sidebar is completely gone. I only want the sidebar to be collapsed by default instead of being expanded.

When I click on the link Daryl, I get an error: No Permission

You cannot view this page

Page level restrictions have been applied that limit access to this page.

Hi Daryl,

thanks for the answer. However, if I remove the code the sidebar is completely gone. I only want the sidebar to be collapsed by default instead of being expanded.

Sry, but I can't get it to work.

The only thing I manage doing is hiding the sidebar. Is there anyone who knows how to collapse the sidebar?

Hello Jum,

I filed a feature request a while ago to have Confluence remember when you had collapsed this sidebar.

https://jira.atlassian.com/browse/CONF-29409

Your requested behavior sounds like another feature request that would relate to this one. Perhaps we could set a java arg to collapse this sidebar by default. Then if confluence is smart enough to remember individual preferences the sidebar can be expanded on a per user basis.

I am happy to file this request on your behalf.

Hi Daniel,

it'd be great if you could file the request on my behalf.

Cheers

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted yesterday in United States

Atlassian Government Symposium

Good day members, Not sure if you are aware that Atlassian will be hosting a Government Symposium on May 1st, 2019 in Washington DC. For more details please click here If you have any questions...

18 views 0 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you