Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-27357

Anchors should link to an expanded content instead of staying closed

    • 15
    • 2
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      NOTE: This suggestion is for Confluence Cloud. Using Confluence Server? See the corresponding suggestion.

      Summary

      An anchor that linked to some content in Expand macro should expand the content automatically instead of expanding it manually.

      Steps to reproduce

      1. Create some content in one page and add an anchor.
      2. Create a new page and add a link to the anchor.
      3. Click the link to the anchor.

      Screenshots

        1. anchor.jpg
          anchor.jpg
          421 kB
        2. link_to_anchor.jpg
          link_to_anchor.jpg
          137 kB
        3. result.jpg
          result.jpg
          77 kB

            [CONFCLOUD-27357] Anchors should link to an expanded content instead of staying closed

            Adam Cupp added a comment - - edited

            This would provide value to us on the Cloud environment... to be able to link to an anchor embedded inside an expanded macro and automatically open up that expanded content when a user is going to that anchor link.  Bump...

            Adam Cupp added a comment - - edited This would provide value to us on the Cloud environment... to be able to link to an anchor embedded inside an expanded macro and automatically open up that expanded content when a user is going to that anchor link.  Bump...

            @Franz Sorry, I'm not sure. Unfortunately I don't have a server environment to try this, and I couldn't find any documentation related to the function. This was just something noted during experimentation.

            David Pezet added a comment - @Franz Sorry, I'm not sure. Unfortunately I don't have a server environment to try this, and I couldn't find any documentation related to the function. This was just something noted during experimentation.

            [@David Pezet|https://jira.atlassian.com/secure/ViewProfile.jspa?name=270122f7c34d:] Should this work also on Confluence Server?

            Franz Steindl added a comment - [@David Pezet| https://jira.atlassian.com/secure/ViewProfile.jspa?name=270122f7c34d :] Should this work also on Confluence Server?

            To have the link expand, the link needs a little [inlineExtension] after the #. e.g., https://site.atlassian.net/wiki/spaces/FOO/pages/123456789/bar#[inlineExtension]heading

            The native heading anchors don't seem to add this and adding the anchor macro tries adding that little function in there, but it converts the brackets in the link which makes it not work. Seems like a bug on the Atlassian side.

            The easiest way to grab a working link is to use the TOC links from the published page. Looks like those don’t convert the brackets.

            David Pezet added a comment - To have the link expand, the link needs a little [inlineExtension] after the # . e.g., https://site.atlassian.net/wiki/spaces/FOO/pages/123456789/bar # [inlineExtension] heading The native heading anchors don't seem to add this and adding the anchor macro tries adding that little function in there, but it converts the brackets in the link which makes it not work. Seems like a bug on the Atlassian side. The easiest way to grab a working link is to use the TOC links from the published page. Looks like those don’t convert the brackets.

            Graham Campbell added a comment - - edited

            I discovered we're using a domain booster, so I'm running into a Same Origin Policy issue. Safely ignore this post

            Hi, I've added this to my Confluence install and I'm getting mixed results. I wonder if you might be able to help me out if I explain it.

            Clicking the link to the heading inside the expand macro does nothing, though the URL updates with the anchor.

            If I reload the page now that the anchor part of the URL is present, the page scrolls and the expand macro opens as expected.

            Why won't this happen on click?

            I'm on Confluence 6.0.5 by the way.

            Graham Campbell added a comment - - edited I discovered we're using a domain booster, so I'm running into a Same Origin Policy issue. Safely ignore this post Hi, I've added this to my Confluence install and I'm getting mixed results. I wonder if you might be able to help me out if I explain it. Clicking the link to the heading inside the expand macro does nothing, though the URL updates with the anchor. If I reload the page now that the anchor part of the URL is present, the page scrolls and the expand macro opens as expected. Why won't this happen on click? I'm on Confluence 6.0.5 by the way.

            @Stephen Deutsch thank you so much for this workaround. 

            Sadly it's not working for me, can someone tell me what I'm doing wrong? 

            I pasted your script in an HTLM macro in my page then put an anchor within an expand macro and created a link to that anchor ("advance" then #anchorname) outside of the expand

            It still behaves as before (the link takes me to the right spot but doesn't expand it)

             

            Ilan Giguel added a comment - @Stephen Deutsch thank you so much for this workaround.  Sadly it's not working for me, can someone tell me what I'm doing wrong?  I pasted your script in an HTLM macro in my page then put an anchor within an expand macro and created a link to that anchor ("advance" then #anchorname) outside of the expand It still behaves as before (the link takes me to the right spot but doesn't expand it)  

            Bar T added a comment -

            Voting for this feature also. We want to keep our documentation clean and usually use the Expand macro to collapse data but want to be able to jump to it easily from other pages.

            Bar T added a comment - Voting for this feature also. We want to keep our documentation clean and usually use the Expand macro to collapse data but want to be able to jump to it easily from other pages.

            Thanks Stanislav, I've updated the code in my comment above.

            Stephen Deutsch added a comment - Thanks Stanislav, I've updated the code in my comment above.

            b4r5uk added a comment -

            to Denise and all: if your url contain non-ASCII text, Mozilla firefox encode URL and macros goes to infinite loop  because URL changes every check in .bind('hashchange'... To avoid this need to replace initial hash assignement

            var hash = window.location.hash;
            
            
            

            with decodeURIComponent(encodedURI) :

            var hash = decodeURIComponent(window.location.hash);
            
            

            works for all browsers!

            b4r5uk added a comment - to Denise and all: if your url contain non-ASCII text, Mozilla firefox encode URL and macros goes to infinite loop  because URL changes every check in .bind('hashchange'... To avoid this need to replace initial hash assignement var hash = window.location.hash; with decodeURIComponent(encodedURI) : var hash = decodeURIComponent(window.location.hash); works for all browsers!

            The ability to easily add anchors within the expand macro that will work without having to edit the source html would be really helpful.

            Denise Wermager added a comment - The ability to easily add anchors within the expand macro that will work without having to edit the source html would be really helpful.

              Unassigned Unassigned
              cchan Chung Park Chan
              Votes:
              133 Vote for this issue
              Watchers:
              62 Start watching this issue

                Created:
                Updated: