- Issue created by @flefle
- π¬π§United Kingdom grahamC Oxford, UK
I have this issue too on a customer site recently upgraded from 9.5 to 10.2.
In the error 'Cannot read properties of undefined', the
undefined
is the off-canvas wrapper element ([data-off-canvas-main-canvas]
)That element was entirely missing for me... It's supposed to be put in place by a
#theme_wrapper
(seesystem_element_info_alter()
) but somehow another module's theme_wrapper is preventing the off-canvas one from running...The offending module for me is Responsive and off-canvas menu β - and commenting out the
responsive_menu_preprocess_html()
function fixes the issue here.@flefle - do you have this module also?
The code that causes the problem is essentially as below:
hook_preprocess_html(&$vars) { $vars['page']['#theme_wrappers'][] = 'responsive_menu_page_wrapper'; }
I can't yet understand what's wrong with adding a theme wrapper like this and why it causes the one from `system` to go missing, though...
- π¨πSwitzerland berdir Switzerland
In the case of @flefle, we tracked this down to an overriden off-canvas-page-wrapper.html.twig template that was missing the data attribute.
While the reason for this error is probably always going to be in contrib/custom modules or themes, it could be argued that off-canvas.js could be more defensive about this situation and avoid a JS error either silently or by doing something like console.warning('Missing data-off-canvas-main-canvas attribute on off-canvas wrapper.
- π©πͺGermany flefle
@grahamC as Sascha mentioned, could you please confirm if the "dialog-off-canvas-main-canvas" within /core/modules/system/templates/off-canvas-page-wrapper.html.twig present is? Was it overwritten maybe and after that the issue occurred?
See also:
https://www.drupal.org/forum/support/theme-development/2019-08-08/how-to... βSuch cases as of: https://www.drupal.org/project/drupal/issues/3409505 π Uncaught TypeError: Cannot read properties of null (reading 'style') (toolbar.js) Needs work should be escaped but the Issue could be fixed by applying the dialog-off-canvas-main-canvas in my case.
- Status changed to Fixed
10 months ago 5:04pm 31 January 2024 Automatically closed - issue fixed for 2 weeks with no activity.
- πΉπThailand peterbkk
To resolve this quickly, I used this module https://www.drupal.org/project/layout_builder_admin_theme β and now layout builder is using admin theme and not my main theme with responsive_menu.