Skip to content

Fix - Navigation script throws a TypeError when #site-navigation is missing - #74

Open
rajatgautam755421 wants to merge 2 commits into
developfrom
fix/28-navigation-guard
Open

rajatgautam755421 wants to merge 2 commits into
developfrom
fix/28-navigation-guard

Conversation

@rajatgautam755421

@rajatgautam755421 rajatgautam755421 commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

The touch-device submenu handler at the end of js/navigation.js read #site-navigation and called container.querySelectorAll() with no null check (the file's first handler already guards it). On any page without that element, such as a child theme whose header.php drops the nav, it throws Uncaught 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:

if ( ! container ) {
    return;
}

Before / After

Before After
before after

Also bumps the radiate-navigation script version (20120206 → 20260930) so browsers that cached the old file load the fixed one (raised by Copilot on the Pro PR).

Testing

  • New spec mobile-menu/navigation-missing-container.spec.ts removes <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.
  • Pages with the nav are unchanged (the guard is an early return only when the element is missing); mobile-menu, header and homepage specs pass, apart from the Pro desktop-width menu spec that also fails on develop.
  • Not reproducible on the block Widgets screen or the Customizer preview on WordPress 7.1.2 with the default header; the trigger is a header without the nav.

🤖 Generated with Claude Code

…igation is missing (themegrill/radiate-pro#28)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants