Fix - Navigation script throws a TypeError when #site-navigation is missing - #74
Open
rajatgautam755421 wants to merge 2 commits into
Open
rajatgautam755421 wants to merge 2 commits into
rajatgautam755421 wants to merge 2 commits into
Conversation
…igation is missing (themegrill/radiate-pro#28) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
QA suite — passed ✅All 7 checks passed. 4 passed · 0 failed · 3 skipped · 0 flaky · 11s Automated check — no AI involved. It runs the tests in this branch. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fix is narrowly scoped and includes regression coverage.
Review effort: Lite
Findings: None
What changed in this PR
Fixes a null dereference in the navigation script when #site-navigation is absent, with regression coverage.
Changes:
- Add an early return when the navigation container is missing.
- Add an E2E test for pages without navigation markup.
| File | Description |
|---|---|
tests/e2e/specs/mobile-menu/navigation-missing-container.spec.ts |
Verifies no script error occurs without the navigation element. |
js/navigation.js |
Guards against a missing navigation container. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ixed file (themegrill/radiate-pro#28) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Summary
The touch-device submenu handler at the end of
js/navigation.jsread#site-navigationand calledcontainer.querySelectorAll()with no null check (the file's first handler already guards it). On any page without that element, such as a child theme whoseheader.phpdrops the nav, it throwsUncaught TypeError: Cannot read properties of null (reading 'querySelectorAll').Closes themegrill/radiate-pro#28 (reported by @subin-shk with steps; duplicate #84)
Fix
Add the same early return the first handler has:
Before / After
Also bumps the
radiate-navigationscript version (20120206→20260930) so browsers that cached the old file load the fixed one (raised by Copilot on the Pro PR).Testing
mobile-menu/navigation-missing-container.spec.tsremoves<nav id="site-navigation">while the page loads and asserts no script error. Passes 3/3; fails on the old code with the exact error above.develop.🤖 Generated with Claude Code