1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

#6797: Fix sidenav jumpy/glitchy behavior on page reload when pinned

This commit is contained in:
checktheroads
2021-08-01 00:27:27 -07:00
parent b86edd4a20
commit 261372289a
6 changed files with 37 additions and 9 deletions

View File

@@ -21,7 +21,7 @@
{# Page title #}
<title>{% block title %}Home{% endblock %} | NetBox</title>
<script>
<script type="text/javascript">
/**
* Determine the best initial color mode to use prior to rendering.
*/
@@ -82,6 +82,21 @@
</head>
<body>
<script type="text/javascript">
(function() {
// Check localStorage to see if the sidebar should be pinned.
var sideNavRaw = localStorage.getItem('netbox-sidenav');
if (typeof sideNavRaw === 'string') {
var sideNavState = JSON.parse(sideNavRaw);
if (sideNavState.pinned === true) {
// If the sidebar should be pinned, set the appropriate body attributes prior to the
// rest of the content rendering. This prevents jumpy/glitchy behavior on page reloads.
document.body.setAttribute('data-sidenav-pinned', '');
document.body.setAttribute('data-sidenav-show', '');
}
}
})();
</script>
{# Page layout #}
{% block layout %}{% endblock %}