fix: hide backoffice navbar-toggler when there's nothing to collapse

The toggler button was always rendered, but its collapse target
(#navbarSupportedContent) only existed for authenticated users. On
the login page, tapping the menu button on a narrow screen did
nothing because the target it pointed at wasn't in the DOM.
This commit is contained in:
2026-07-12 20:25:22 +02:00
parent f3d6984622
commit 38411dd44b
2 changed files with 27 additions and 9 deletions
+18
View File
@@ -19,6 +19,24 @@ final class LoginControllerTest extends AbstractControllerWebTestCase
self::assertSelectorExists('form');
}
public function testNavbarTogglerHasNoDeadTargetWhenNotAuthenticated(): void
{
$this->client->request(Request::METHOD_GET, '/login');
$crawler = $this->client->getCrawler();
$toggler = $crawler->filter('.navbar-toggler');
if (0 === $toggler->count()) {
self::assertSelectorNotExists('#navbarSupportedContent');
return;
}
$target = $toggler->attr('data-bs-target');
$this->assertNotNull($target);
self::assertSelectorExists($target);
}
public function testLoginRedirectsToBackofficeWhenAlreadyAuthenticated(): void
{
$this->loginAs('test@example.org');