Is there an easy way to set up collapse and expand Quick Launch headings in Sharepoint Online?
As there is still no solution from Microsoft (!!!) – I just used this one – easy to install and to deploy and it will just open and show all sub-links at the left navigation: https://www.tecconsult.at/products/sharepoint-auto-expand-left-navigation/
Do you know of any good javascript that would accomplish this and where to put the code? I think it would be called a javascript injection (rather than customizing the default masterpage which I think would cause the code to be overwritten with any MS upgrade to sharepoint online).
There is no “easy” way per say. You can use JavaScript to do this. However, be aware, the implementation would change from Classic to Modern.
Marc has some code for classic SharePoint http://sympmarc.com/2015/05/27/simple-expandcollapse-for-the-quick-launch-in-sharepoint-2013-or-sharepoint-online/
I don’t have one on hand for Modern. But you are correct, you would use javascript injection. For classic, you’ll inject it. For Modern, you’ll use an application customizer to inject it.