Problem/Motivation
Olivero currently has an expectation that the primary and secondary navigation items will always exist. It will throw JS errors if they do not.
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
at isDesktopNav (js_I3-LxdtjvE_IegIbuj2Um5FE1PkkICsN37a3UrDLN8M.js:463)
at toggleStickyHeaderState (js_I3-LxdtjvE_IegIbuj2Um5FE1PkkICsN37a3UrDLN8M.js:484)
at js_I3-LxdtjvE_IegIbuj2Um5FE1PkkICsN37a3UrDLN8M.js:570
at js_I3-LxdtjvE_IegIbuj2Um5FE1PkkICsN37a3UrDLN8M.js:572
and
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
at isDesktopNav (js_I3-LxdtjvE_IegIbuj2Um5FE1PkkICsN37a3UrDLN8M.js:463)
at IntersectionObserver.toggleDesktopNavVisibility (js_I3-LxdtjvE_IegIbuj2Um5FE1PkkICsN37a3UrDLN8M.js:514)
Steps to reproduce
Remove primary menu block and then look at the JavaScript Console.
To do
Remove primary and secondary nav assets from global styles and only load them when necessary. Add condition within JS so it doesn't throw errors when determining if Olivero is in its desktop nav configuration.
Comments
Comment #2
davidwbarratt commentedComment #3
mherchelThis is a great bug, thanks @davidwbarratt!
Olivero is expecting the primary menu to exist, but it doesn't on your site. I'm going to massage the summary a bit, and then post a patch.
Comment #4
mherchelComment #5
mherchelThis should resolve it.
Comment #6
davidwbarratt commentedDeployed to my site:
https://github.com/davidbarratt/davidwbarratt/blob/f70cdfb9abcc09f061d0b...
and that fixed the problem!
https://davidwbarratt.com/
Thanks!
Comment #7
mherchelSweet :)
I'm setting this back to needs review. I've created a Nightwatch test for this, but I'm not sure this is the best way to go about testing it.
Ideally, there could be a
noConsoleErrorsassertion or something, but I couldn't find an easy way to do that (and pass the errors back), plus its out of scope of this issue.Comment #8
mherchelForgot to run prettier. New patches attached.
Comment #9
mherchelLets try this again.
Comment #10
mherchelThird times a charm
🤞🤞🤞🤞🤞🤞🤞
Comment #11
gauravvvv commentedPatch #10, fixes the issue.
Testing steps:
1. Remove the primary menu block and then look at the JavaScript Console.
Got two js error messages in console
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.Testing results:
Patch applied #10, No js error messages in the console.
Added before and after patch screenshots for reference.
Comment #12
andy-blumComment #13
mherchelComment #14
ankithashettyRerolled the patch in #10, thanks!
Comment #15
mherchelIt looks like the re-roll in #14 didn't include the changes in navigation-utils.es6.js.
Also, the diffs between two patch files aren't especially helpful. We need the diff between the code itself when attaching an interdiff.
Comment #16
mherchelLooks like the changes in navigation-utils.es6.js are already committed to core via #3194560: Style maintenance page for Olivero.
Comment #17
mherchelRe-uploading patch and also the test only. I'm not sure the test will fail since the JS fix committed as part of #3194560: Style maintenance page for Olivero
Comment #18
chetanbharambe commentedVerified and tested patch #17.
Patch applied successfully and looks good to me.
Testing Steps:
# Goto: Appearance -> Apply Olivero theme
# Goto: /admin/structure/block
# Remove the primary menu block
Expected Results:
# User should not see JS errors in Console
Note: Currently there are no errors coming in the console before applying the patch.
Please refer attached screenshots for the same.
Looks good to me.
Can be a move to RTBC.
Comment #19
alexpottNice test and even if the bug is fixed by the other issue I think this approach makes lots of sense.
Committed 7578516 and pushed to 9.3.x. Thanks!