diff --git a/client/src/components/Sidebar/index.tsx b/client/src/components/Sidebar/index.tsx index 21b291ddff..cbac09a55b 100644 --- a/client/src/components/Sidebar/index.tsx +++ b/client/src/components/Sidebar/index.tsx @@ -8,6 +8,7 @@ export const SIDEBAR_COLLAPSED_COOKIE_NAME = 'wagtail_sidebar_collapsed'; export function initSidebar() { const element = document.getElementById('wagtail-sidebar'); + const rawProps = document.getElementById('wagtail-sidebar-props'); const navigate = (url: string) => { window.location.href = url; @@ -20,8 +21,8 @@ export function initSidebar() { return new Promise(() => {}); }; - if (element instanceof HTMLElement && element.dataset.props) { - const props = window.telepath.unpack(JSON.parse(element.dataset.props)); + if (element && rawProps?.textContent) { + const props = window.telepath.unpack(JSON.parse(rawProps.textContent)); const collapsedCookie: any = Cookies.get(SIDEBAR_COLLAPSED_COOKIE_NAME); // Cast to boolean diff --git a/wagtail/admin/templates/wagtailadmin/base.html b/wagtail/admin/templates/wagtailadmin/base.html index 6e39a65f07..a885b90823 100644 --- a/wagtail/admin/templates/wagtailadmin/base.html +++ b/wagtail/admin/templates/wagtailadmin/base.html @@ -5,7 +5,8 @@ {% slim_sidebar_enabled as slim_sidebar_enabled %} {% if slim_sidebar_enabled %} - + + {% else %}