SOLVED

URL query string to expand collapsed section on page?

Steel Contributor

I've been using collapsible sections (a LOT) lately to create FAQ type pages in SharePoint. It makes for a very intuitive interface for viewers in the site. Sometimes, though, we want to point someone to a particular question. Since each section's "title" is a heading (h2), it's easy to hover over it, right-click the chain link icon and select "copy link". The issue, though, is that if the section is configured to be collapsed by default, when someone uses that link, it's still collapsed. Yes, they just need to click the caret icon to expand it, but it'd be better if there were a way to modify the link to expand that section. For example, adding a query string parameter (e.g.: ?sectionMode=expanded). 

 

I've been poking at it using Edge's developer tools, trying to identify what exactly happens when that expand/collapse icon is clicked, but had no luck. Anyone else have any idea how this might be accomplished?

13 Replies
I need this too. Thanks Chad.
@Chad_V_Kealey : Thanks to @simigu who linked our questions. I need this feature, too. But as there are two streams now. I marked simigu's response on my thread as a soltion and consider this thread as leading part of the discussion.
Hopefully there will be a solution soon.

fyi: Sadly @ganeshsanap didn't find a solution for this problem, too.

https://techcommunity.microsoft.com/t5/sharepoint/sharepoint-online-collapsible-sections-on-modern-p...

 

(See end of discussion)

best response confirmed by Chad_V_Kealey (Steel Contributor)
Solution
Add a Text with header format in the section. Sharepoint will give this header a page anchor automatically. Link to this page anchor via URL. The section will now be expanded.
@StevenNeele
Thank you. Yes, this works. Tried this out with a 'Heading 2' formatted text, works as described. Visiting the URL brings you straight to the text, with the section being expanded. So, this is the solution.
Works for me too! Thanks!
That's A solution, but may not be ideal in some cases. For example, if you're using collapsing sections to create an FAQ page. One of the questions is "How do I change my password?", so you create a collapsible section with that title (so it's visible when the section is collapsed. The method you're suggesting would require duplicating the question (or at least adding a heading) inside that section. Sure, you could make it something like "Answer:" so you're not duplicating the question, but that would still look a bit off.

Ideally, since every collapsible section has a heading-formatted title, there would be an option/setting along the lines of "Expand section on focus".

@Chad_V_Kealey Indeed, this is a workaround and not the best solution. But for now in some cases it can do the trick!

You're definitivly right. The solution is only a work around. For my case it is sufficient. (I'm lucky: Each of my Sections already had a structure with four given headlines).
If I now link to the first headline in the section I have the problem that the title is cut off (because the headline is top of the page).
-->So it is still the best solution - but hopefully in one of the next releases there will be something built in (including a feature that expanded section will be automatically collapsed if you use another link to switch the "questions" on the page....
Thanks for asking this question I'm having the same issue, using the links to create a sitemap and where there are many collapsed sections it would be helpful for the links to open the sections. The workaround that people have mentioned is good but doesn't address the issue for me as like others have said I'd have to have 2 titles.

@HE_MykeI think I found another workaround to add to this. Funny enough you can have a single 'space' character at the end of the section, format is as Heading 4, change to the smallest font size if you like, and the anchor link still works. This solved for me.

Additionally, you could format every text section as Heading 4, Font size 16.
1 best response

Accepted Solutions
best response confirmed by Chad_V_Kealey (Steel Contributor)
Solution
Add a Text with header format in the section. Sharepoint will give this header a page anchor automatically. Link to this page anchor via URL. The section will now be expanded.

View solution in original post