-
Suggestion
-
Resolution: Unresolved
-
None
-
6
-
4
-
We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.
NOTE: This suggestion is for Confluence Server. Using Confluence Cloud? 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
- Create some content in one page and add an anchor.
- Create a new page and add a link to the anchor.
- Click the link to the anchor.
Screenshots
- anchor.jpg
- 421 kB
- Chung Park Chan
- link_to_anchor.jpg
- 137 kB
- Chung Park Chan
- result.jpg
- 77 kB
- Chung Park Chan
- relates to
-
CONFCLOUD-27357 Anchors should link to an expanded content instead of staying closed
- Gathering Interest
-
CONFSERVER-27077 Option to display expand macro expanded/collapsed on page load
- Not Being Considered
- mentioned in
-
Page Failed to load
[CONFSERVER-27357] Anchors should link to an expanded content instead of staying closed
No, unfortunately not.
The Table of Contents does not work at all when the Heading is placed in Expand macro.
Semms like there's no workaround solution for Confluence Server then
f8a5494ffe6a Do the Table of Contents macro links work? You might have luck looking at how those are constructed in your version.
Tested on Confluence Server 7.13.7, unfortunately, the [inlineExtension] does not work for me.
The whole anchor mechanism seems not to be working at all when it's inside the expand macro - it doesn't even navigate to the proper section of the page, just stays at the top.
Although I haven't tried this in the Server version, the following it what I had noticed in the Cloud version (as commented on CONFCLOUD-27357) If any Server users could try, it might help!
"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."
I am quite sure this issue will not win any more attention since it's create for server versions. Someone with the permissions has to link it to a datacenter issue...?
Until you are able to have people who are able to implement excellent suggestions made in this forum for this almost decade old problem, perhaps you could add a couple of lines to the documentation on the Expand macro, indicating the limitation and how best to workaround the problem? This would demonstrate that you "appreciate the benefits of such requests." If you don't plan to work on this for the foreseeable future, can you detail how foreseeable your future is, because you are now part of our risk management considerations.
This is such a fundamental flaw I can't believe it made it into production. You present a user with links for the express and (justifiably) expected purpose of navigating the page but some just don't work? And for no identifiable reason, not even a clue, from the user's perspective.
Either don't include headings in the TOC that are inside collapsed content on the page, or make all the TOC links work as users expect from 30+ years of ubiquitous and uniform digital interaction.
Sorry to be harsh but as space owners, we bare the brunt of the fallout, looking incompetent and facing the understandably frustrated users.
Like a previous comment mentioned, pages with lots of information packed in expand macros are hard to link to from other pages - quite frankly, the anchor functionality is a bit broken, as it is now.
I therefore urge the implementation of this feature.
The original workaround script wasn't working for me because chrome wasn't firing `haschange` event on the window object for some reason. I switched the script to use polling and everything works. See below:
<script> var expandAnchor = function() { var hash = decodeURIComponent(window.location.hash); if (hash) { var hashPageTitle = AJS.params.pageTitle.split(" ").join(""); if (hash.indexOf(hashPageTitle) === -1) { if (jQuery.isNumeric(hashPageTitle.substring(0,1))) { hash = "#id-" + hashPageTitle + "-" + hash.slice(1); } else { hash = "#" + hashPageTitle + "-" + hash.slice(1); } } var escapedId = hash.replace(/[!"$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&"); jQuery(escapedId).parents('.expand-container').children('.expand-hidden').prev().click(); window.location.href=hash; } } AJS.toInit(function() { // handle initial page load expandAnchor(); // use polling because hashchange event doesn't fire for some reason function hashHandler(){ this.oldHash = window.location.hash; this.Check; var that = this; var detect = function(){ if(that.oldHash!=window.location.hash){ console.log("HASH CHANGED - new has" + window.location.hash); expandAnchor(); that.oldHash = window.location.hash; } }; this.Check = setInterval(function(){ detect() }, 100); } var hashDetection = new hashHandler(); }); </script>
It seems I am in the same boat as others who don't have access to the html code. This is rather a debilitating issue for heavy users of Confluence trying to communicate a great volume of information in an organized fashion for which the Expand macros is incredibly helpful. However suddenly, what was a helpful way of simplifying/outlining information is made null and void when a table of contents can't be linked to the expanded section. I assume no one would see this as the intended user experience so because I appreciate the prioritization process I'm making this comment to keep interest alive in hopes the "Not Being Considered" for 12+ months status might be updated
Thanks for your interest in this issue.
While this suggestion has gathered significant interest, we're unable to implement all of the excellent suggestions you make. We appreciate the benefits of such requests, but don't plan to work on this for the foreseeable future.
This suggestion will be reviewed in about 12 months time, at which point we’ll consider whether we need to alter its status.
Cheers,
Confluence Product Management
Graham Campbell thank you for the updated script. Unfortunately i still have the same behaviour... the url changes accordingly but the display doesn't change unless i refresh the page manually. I see Keith Shaw also has the same issue so i guess it's the normal behaviour now...
I can't see the logic behind this... what use is the expand macro if you can't link to the expanded section ?! It doesn't work with the TOC, and makes navigation very difficult. We use Confluence for all our documentation and some procedures are pretty heavy. Expandables seemed like the solution but since you can't link to the contents from the TOC they are not only useless, but more of an impediment. I'd seriously conssider suppressing them only i can't justify wasting all that time!
Hi Andra - I've since updated the version of the script I copied from Stephen's answer slightly. Here is what I am currently using in the Custom HTML:
var expandAnchor = function() { var hash = decodeURIComponent(window.location.hash); if (hash) { var splitHash = hash.split("-"); if (splitHash[1] == "tab" && splitHash[2] !== "undefined") { var tablinks = document.getElementsByClassName('rwui_tab_button'); var linkText = splitHash[2].replace(/\+/g," "); for (tl=0;tl<tablinks.length;tl++) { if (tablinks[tl].innerHTML == linkText) { tablinks[tl].click(); tablinks[tl].scrollIntoView(true); } } } else { var hashPageTitle = AJS.params.pageTitle.split(" ").join(""); if (hash.indexOf(hashPageTitle) === -1) { if (jQuery.isNumeric(hashPageTitle.substring(0,1))) { hash = "#id-" + hashPageTitle + "-" + hash.slice(1); } else { hash = "#" + hashPageTitle + "-" + hash.slice(1); } } var escapedId = hash.replace(/[!"$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&"); jQuery(escapedId).parents('.expand-container').children('.expand-hidden').prev().click(); window.location.href=hash; } } } AJS.toInit(function() { expandAnchor(); });
Hey, i've tried adding the macro, and also adding the script to the custom html at the end of the body like Graham Campbel said, but i still need to refresh the page in order to view the expanded macro... Anyone has a fix for this ?
Is there something non-admins can do? Not being able to expand the sections through anchor links really impedes the navigation experience. We are heavy users of Confluence throughout the company so these navigation constraints impact us heavily.
We have set up Confluence to manage our business processes, but now find we cannot navigate from the Task Report page to the Task in the Expand macro.
This is a major problem and it is quite astonishing Atlassian have not rectified.
Dear confluence project management & development team,
I want to start out on the positive note that our company LOVES Confluence.
But issues like this along with the fact that it has been a feature request for over 6 years is sad.
We encourage the use of the expand macro because it reduces clutter but due to this issue we are using it less.
Your dedicated user base has been keeping this thread alive but it appears we are all being left in the dark with no one from Atlassian providing feedback other than moving it from the new status it has been in for over 5 years to New then Needs Verification and now Gathering Interest without anyone from the teams replying to the public comments.
I know your teams care about the customer and wont bull$!@& us but leaving us hanging for 6 years is another form of bull$!@&
(quoting the company value makes me sound more mad than I actually am by the way & I am sorry for that but won't change)
Again we all still love your company but we are disappointed this is considered a feature request and that it is stuck in limbo. Free wikis available online handle expand macros and anchors better than Confluence and we consider Confluence to be the top of the line Wiki.
stephendeutsch1's workaround created 4 years ago now requires you refresh the page manually before it works. If anyone has adjusted it to work without refreshing the page please let me know. I will be looking into adding a way to force it to refresh the page when used & will share it with the group if I get it to work.
Hi trae, have you tried adding it to your Custom HTML? If you have access to your Confluence's General Configuration and view the Custom HTML screen here:
your.confluence.url/admin/viewcustomhtml.action
Then add Stephen's script to the end of the body section, it should work perfectly.
You must add it to the end though, so that the script is loaded last and it can properly target the rendered headings. Good luck!
I am running Confluence 6.1.2 and I can't get stephendeutsch1's java script to work. I've tried the various ways of adding the java script to macros (html macro does nothing, markup throws a bunch of unknown macro errors within yellow boxes with the offending script highlighted), but I still can't link to anchors within expand macros.
If I manually expand the macros, the anchors work fine. This really should be officially fixed. I can't understand why it isn't. How many votes do you need???
I'd previously had no luck with Stephen Deutsch's macro solution.
However, when I use his script exactly as he's posted it above in my Custom HTML (inside some <script>...</script> tags) then it works perfectly.
Note that it only works with the vanilla Expand macro, not with any others such as the UI Expand macro.
For reference, I'm on Confluence 6.0.6 and using 64-bit Chrome version 63.
Good luck!
Has there been any update on this being resolved? Seems like something that would be used quite a bit I'm surprised they have not implemented the functionality yet.
I've tried the above custom solution but haven't had any success. Does any have an update on this by chance?
Hey Chris Cannata, in short we didn't resolve it. We're still using the domain booster and I still have that same problem. I've started investigating this issue again for our Confluence install to see if I can insert JavaScript in the Custom HTML to handle this issue. If I figure it out I'll post again with my solution.
Ach, I just wrote a whole document with multiple Expand macros to hide content.
I put Anchor links all over the place, but none of them work!
Hi Atlassian, any news on this? We've just created a lengthy API document and surprise, surprise none of the anchor links within the expand macros work. Any chance of fixing this? Slightly concerning that this isn't the first Confluence bug I've come across that is five years old...
Hello Graham, we are running into the same issue it looks like you encountered. How did you resolve the Same Origin Policy issue?
Same with tasks! When we click on the link under "Task appears on" on a task list, it redirects to the right page but if the task itself is within an expandable macro, it will remain closed.
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)
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.
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.
Never mind. I figured it out. It works beautifully. @luke hart, you can copy the code from above and paste it into the
{html}macro anywhere on your page. Once you save the page, your Links will be able to open "Expand" macros. Good luck!
I would love to see this feature as well. I would like to try @stephen Deutsch's javascript, but I'm not really sure how to apply it. Can someone dumb-down the explanation a bit for me? Thanks!
Yes, this feature would be great.
Yesterday I actually set some anchors up this way, assuming that an anchor to an expand macro would automatically expand it. Nope. It does seem like this is an obvious feature. Please implement.
@Stephen Deutsch
Thank you very much to share your javascript with us. I have tested your code in our instance and it's working fine!
Thanks a lot,
Cheers
Tobias
I ended up writing a workaround for one of our spaces, maybe someone else will find it helpful. What I did was create a user macro that had this content:
## @noparams <script> var expandAnchor = function() { var hash = decodeURIComponent(window.location.hash); if (hash) { var hashPageTitle = AJS.params.pageTitle.split(" ").join(""); if (hash.indexOf(hashPageTitle) === -1) { if (jQuery.isNumeric(hashPageTitle.substring(0,1))) { hash = "#id-" + hashPageTitle + "-" + hash.slice(1); } else { hash = "#" + hashPageTitle + "-" + hash.slice(1); } } var escapedId = hash.replace(/[!"$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&"); jQuery(escapedId).parents('.expand-container').children('.expand-hidden').prev().click(); window.location.href=hash; } } AJS.toInit(function() { expandAnchor(); jQuery(window).bind('hashchange', function() { expandAnchor(); }); }); </script>
Then I added this macro (in wiki markup format, i.e. {macro-name}) to the documentation theme to be in the footer.
Alternatively, you could put it on every page by choosing custom HTML in the admin settings (copy everything except the first line).
EDIT: updated to fix some bugs and to automatically insert the name of the page into the hashtags if it is not already there
ANOTHER EDIT: I realized that if a page begins with a number, the anchor syntax is slightly different, so I updated the code to fix this.
Very important issue for me, I hope this feature will be implemented soon
This seems such an obvious feature to have when trying to make readable pages without having an unnecessary page hierarchy. Please can this be added.
Will this feature be implemented in the nearest future?
It is quite mandatory for the interactivity required in our space.
I found a problem with the script above.
This script is causing this issue: Confluence displays a second "Delete page" pop up for a parent page when deleting a child page.
See: https://confluence.atlassian.com/confkb/confluence-displays-a-second-delete-page-pop-up-for-a-parent-page-when-deleting-a-child-page-1062240816.html
I'm not sure if we need to maintain code which was originally designed in 2014...
In order to fix this, just remove the redirect:
window.location.href=hash;
This will cause the page to reload.