I have lost count of how often I customised a SharePoint view only to run into the same issue over and over – the ribbon vanishes afterwards.
The ribbon of that view stays hidden until you click one of the items in the list.

… and every single time I have to look up how I worked around the issue to make the menu show up again. Maybe this write-up helps someone else too. 🙂
In essence we need a short JavaScript snippet that re-activates the list view web part, because the menu appears to be linked to it. By customising the page we somehow change this connection so SharePoint no longer recognises the web part as a view. Microsoft’s rather clumsy workaround is simply to hide the menu instead of checking whether the list view required for the ribbon is still on the page.
Here is the script to bring the ribbon back. Add a Script Editor web part to the page, paste the snippet and replace the element ID MSOZoneCell_WebPartWPQ1 with the ID used on your page:
<script>
ExecuteOrDelayUntilScriptLoaded(init_defaultWP, "sp.ribbon.js");
function init_defaultWP() {
setTimeout(function () {
var defaultWP = document.getElementById("MSOZoneCell_WebPartWPQ1");
WpClick({ target: defaultWP, srcElement: defaultWP });
}, 100);
}
</script>
And just like that, everything is back in shape! 🙂

The ribbon menu is now visible again.
That’s it for today – see you next time! 😉