Fix - navigation.js null errors on pages without the theme header - #147
Open
rajatgautam755421 wants to merge 1 commit into
Open
rajatgautam755421 wants to merge 1 commit into
rajatgautam755421 wants to merge 1 commit into
Conversation
…dgets screen previews) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QA suite — refused, no regression specThis PR changes product source but adds no spec, so the suite was Source files changed with no matching spec |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The guards address the reported errors while preserving existing navigation behavior.
Review effort: Lite
Findings: None
What changed in this PR
Fixes null errors in navigation.js on pages without the theme header.
Changes:
- Guards tablet submenu initialization when
#site-navigationis absent. - Guards one-line menu setup against missing navigation markup.
| File | Description |
|---|---|
js/navigation.js |
Adds null checks for header-dependent navigation logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request:
Free-theme part of themegrill/spacious-pro#85. Pro PR: themegrill/spacious-pro#197.
js/navigation.jsassumes the theme header is on the page. On wp-admin > Widgets every block preview iframe loads the theme's front-end scripts but has no header, so it throwsCannot read properties of null (reading 'querySelectorAll')atnavigation.js:80, once per preview (11 on a default setup).This adds two guards where the header was used unchecked:
#site-navigationis missing.#site-navigationis missing (the widths above it already fall back to 0).The free version needs fewer guards than Pro: its out-of-viewport submenu code uses jQuery only, and its ready handler already guards the width lookups.
Effect on existing sites
How to test the changes in this Pull Request:
TypeError: Cannot read properties of null (reading 'querySelectorAll')atnavigation.js:80, once per preview. After: none.Types of changes:
Other information:
Changelog entry
Fix - JavaScript errors from navigation.js on the Widgets screen and other pages without the theme header.
Verification (WordPress 7.1.2, theme 1.9.12)
navigation.jserrors (11 previews loading the free theme's script)core/interfacealready registered).jshintrc): same messages asdevelop, none added.🤖 Generated with Claude Code