Skip to content

Commit 710cac3

Browse files
simonhampclaude
andcommitted
Fix mobile nav menu closing immediately on larger screens
Use window.matchMedia('(min-width: 80rem)') instead of a hardcoded pixel comparison in the x-resize handler. The mismatch between the CSS breakpoint (80rem) and the JS check (1280px) caused the menu to close immediately when scrollbar removal changed the body width. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cc42a6a commit 710cac3

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

resources/views/components/layout.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
}"
105105
x-resize="
106106
width = $width
107-
if (width >= 1280) {
107+
if (window.matchMedia('(min-width: 80rem)').matches) {
108108
showMobileMenu = false
109109
showDocsMenu = false
110110
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Tests\Feature;
4+
5+
use Illuminate\Foundation\Testing\RefreshDatabase;
6+
use Tests\TestCase;
7+
8+
class NavigationMobileMenuBreakpointTest extends TestCase
9+
{
10+
use RefreshDatabase;
11+
12+
public function test_mobile_menu_resize_handler_uses_media_query_breakpoint(): void
13+
{
14+
$response = $this->get('/');
15+
16+
$response->assertStatus(200);
17+
$response->assertSee("window.matchMedia('(min-width: 80rem)').matches", false);
18+
}
19+
}

0 commit comments

Comments
 (0)