Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can't jump to Anchor in Expand macro

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 16, 2016

I've got a page with several Expand macros on it.

Below these on the page (and not within the Expand macro) are sets of data that contain links to headings within the Expand macro. The headings have the Anchor macro.

If you click on the link that goes to one of the headings within the Expand macro, and it is NOT already expanded, then the link doesn't work.

If you expand the area you want to jump to first, then click on the link, you jump to the appropriate heading.

 

I hope that makes sense. smile

Is this expected behaviour or a bug?

I'm running Confluence Server, 5.4.1.

Cheers.

2 answers

1 accepted

2 votes
Answer accepted
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2016

This is a known issue:

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

However, if you look in the comments of the ticket, I wrote a workaround where you can add some Javascript to your Confluence instance that will enable this.  If you copy everything except the first line into your custom HTML, then it should work on all your pages.

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2016

Stephen, that's great, thank you.

Brandon Roesler June 8, 2017

This work-around used to work great for me, but now that my company has upgraded to 6.0.7, none of my links work any longer.  Any suggestions?

Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2017

strange, I tested it on Confluence Cloud, which should be the latest version, and it worked OK... Might something else have changed during the upgrade?

Jeff Robertz February 6, 2018

Guys, I a newbie to such things. Where do you need to copy the macro in Confluence cloud?

Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 7, 2018

Hi Jeff,

unfortunately it will currently not work for all users in Confluence Cloud, as there are restrictions as to what you can do especially when it comes to custom HTML/Javascript. You could install a browser extension such as Greasemonkey/Tampermonkey and package it as a user script, but it would only work for those users with the user script and browser plugin activated.

Scott Fordin March 28, 2018

Thanks so much, Stephen. Your code works beautifully! I have one minor niggle though for which I haven't been able to figure out a workaround...

To make your expand trick work for a given targeted text block in an Expand macro, the Anchor macro for that targeted text must be embedded within (not before) the Expand macro in which the text block is contained. So far, so good, yes?

However, because the Anchor macro is embedded in the Expand macro, when a user follows a link to the targeted page, the page is opened and the viewport is scrolled to the expanded content, just past the Expand macro's title string. So, the user sees the expanded content, but does not see the title string for that content, which can be disorienting.

I've been trying to find a way, using JavaScript and/or JQuery, to scroll the viewport up just one line after the page is loaded and the expanded text is opened. Any recommendations? I know it's a no-no in most cases to grab control of the input focus. All I want to do is shift the viewport up by one line. Alternatively, I suppose I could add a redundant or similar title string in the Expand text block, but that's icky from a doc standpoint.

Thanks again!

Tim Bisaerts October 23, 2019

The solution works great!

Did someone by accident find a solution for the ui-expand function (part of the RefinedToolkit plugin)

0 votes
Екатерина Мельник August 4, 2020

Hi, guys!

So basically this workaround can be applied only if you administrator. Otherwise you cannot do anything, and the issue is not going to be fixed. 

Am I right?

Regards,

Kate

Mario Siebeck January 7, 2021

No

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events