Skip to content

fix(layout): passar sidebarOpen para Header (corrige UI completa quebrada)#91

Closed
adm01-debug wants to merge 2 commits into
mainfrom
claude/fix-header-sidebar-open-prop
Closed

fix(layout): passar sidebarOpen para Header (corrige UI completa quebrada)#91
adm01-debug wants to merge 2 commits into
mainfrom
claude/fix-header-sidebar-open-prop

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 22, 2026

🎯 ESTE É O FIX DEFINITIVO da sidebar/header sumida e "Falha no Módulo"

Diagnóstico

Consulta direto na tabela frontend_telemetry mostrou 82 ocorrências do mesmo ReferenceError em ~5h:

sidebarOpen is not defined
  → pathname: '/' e '/orcamentos/novo'

Localizado em src/components/layout/Header.tsx linhas 151-152:

<Button
  ...
  aria-label={sidebarOpen ? "Fechar menu" : "Abrir menu"}  // ← referência
  aria-expanded={sidebarOpen}                              // ← referência
>

A variável sidebarOpen só existe no escopo do MainLayout.tsx. Não está nas props do Header nem em qualquer outro lugar acessível.

Cascata do bug

  1. <Header /> lança ReferenceError: sidebarOpen is not defined na render
  2. Em alguns casos, o <Suspense> que envolve o Header captura e fica preso no fallback (div invisível) → sidebar e header somem silenciosamente
  3. Em outros casos, o erro bubla até o EnhancedErrorBoundary global em ProtectedRoute.tsxtela "Falha no Módulo" full-screen

Por isso o sintoma "variava" entre apenas sumir e quebrar tudo — dependia de qual Suspense capturava primeiro.

Fix

  1. Adicionar sidebarOpen: boolean na interface HeaderProps
  2. Desestruturar junto com onMenuToggle
  3. Passar do MainLayout (que tem o useState) pro <Header />
  4. Limpar props mortas (searchQuery/onSearchChange não fluíam pra lugar nenhum — search é via useSearchStore)
  5. Limpeza de imports/vars não usados que o lint-staged pegou ao tocar nos arquivos

Teste manual

  • Após deploy, abrir https://promogifts.com.br em janela anônima
  • Sidebar à esquerda deve aparecer (Orçamentos, Catálogo, Ferramentas, Insights, Admin)
  • Header no topo deve aparecer (logo, busca, notificações, perfil)
  • Botão hambúrguer em mobile abre/fecha sidebar
  • Refresh em qualquer rota interna mantém o layout

Sequência de PRs hoje

# Fix
#34 CLI Supabase versão fixa (rate limit)
#36 client.ts apontando pro banco certo
#39 CORS *.vercel.app
#40 Categorias resolvendo nome real
#41 OptimizedImage onLoad/onError
#42 vercel.json SPA rewrite
#43 (este) sidebarOpen prop — UI volta inteira

https://claude.ai/code/session_01CUVPfuj5W2dNtPNPAL7iA7


Generated by Claude Code


Summary by cubic

Passes the sidebarOpen state from MainLayout to Header to stop a render-time ReferenceError and restore the header/sidebar across the app. Prevents the intermittent “Falha no Módulo” screen and missing layout.

  • Bug Fixes

    • Added sidebarOpen: boolean to HeaderProps and used it for the hamburger button aria-label and aria-expanded.
    • Passed sidebarOpen from MainLayout into <Header />.
    • Removed dead searchQuery/onSearchChange props (search is via useSearchStore).
    • Eliminated the sidebarOpen is not defined crash that hid the header/sidebar or triggered the global error screen.
  • Refactors

    • Cleaned unused imports/vars touched by the change.
    • Test/lint hygiene: type-only import in AuthContext.test.tsx and stricter mock callback type in AdminLayout.test.tsx (no runtime changes).

Written for commit fe0d196. Summary will update on new commits. Review in cubic

claude added 2 commits May 22, 2026 09:43
…MainLayout)

Header.tsx referenced `sidebarOpen` on lines 151-152 (aria-label and
aria-expanded for the hamburger button) but the variable was neither
declared in props nor in the component's scope — it only existed in
MainLayout.tsx. Every render of <Header /> threw ReferenceError:
sidebarOpen is not defined, which bubbled up to the global
EnhancedErrorBoundary in ProtectedRoute and showed "Falha no Módulo".

Sometimes the inner Suspense of <Header> caught it and just hid the
header silently (sidebar/header both missing because the same condition
caused a different render-time failure). Other sessions hit the outer
boundary and showed the full module-failure UI.

Telemetry confirms 82 occurrences of this exact ReferenceError in the
last ~5 hours on '/' and '/orcamentos/novo'.

Fix:
  • Add `sidebarOpen: boolean` to HeaderProps and destructure it
  • Pass it from MainLayout (where the state lives) into <Header />
  • Drop the unused searchQuery/onSearchChange props that no longer
    flowed anywhere (search state is owned by useSearchStore)
  • Clean up the unused imports the lint-staged hook caught while we
    were touching these files (Settings, RotateCcw, getRoleLabel,
    BackButton, isMockupGenerator, hasCompletedTour, etc.)

https://claude.ai/code/session_01CUVPfuj5W2dNtPNPAL7iA7
…-explicit-any)

Two test files that the Lovable bot recently touched introduced new
ESLint baseline regressions which started blocking the pre-push hook
on unrelated branches:

- src/contexts/AuthContext.test.tsx: `import()` type annotation
  forbidden by @typescript-eslint/consistent-type-imports. Hoisted the
  type-only import to the top of the file and reused via typeof.
- src/tests/AdminLayout.test.tsx: explicit `any` on a mock callback.
  Tightened to the actual callback shape vi.fn() expects.

These are surgical lint-only fixes in tests; no runtime behaviour
changes.

https://claude.ai/code/session_01CUVPfuj5W2dNtPNPAL7iA7
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
we-dream-big Ready Ready Preview, Comment May 22, 2026 9:49am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aad74912-2b55-4606-850c-9716b384afd7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-header-sidebar-open-prop

Comment @coderabbitai help to get the list of available commands and usage tips.

@supabase
Copy link
Copy Markdown

supabase Bot commented May 22, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

adm01-debug added a commit that referenced this pull request May 22, 2026
* fix(layout): pass sidebarOpen prop to Header (ReferenceError crashed MainLayout)

Header.tsx referenced `sidebarOpen` on lines 151-152 (aria-label and
aria-expanded for the hamburger button) but the variable was neither
declared in props nor in the component's scope — it only existed in
MainLayout.tsx. Every render of <Header /> threw ReferenceError:
sidebarOpen is not defined, which bubbled up to the global
EnhancedErrorBoundary in ProtectedRoute and showed "Falha no Módulo".

Sometimes the inner Suspense of <Header> caught it and just hid the
header silently (sidebar/header both missing because the same condition
caused a different render-time failure). Other sessions hit the outer
boundary and showed the full module-failure UI.

Telemetry confirms 82 occurrences of this exact ReferenceError in the
last ~5 hours on '/' and '/orcamentos/novo'.

Fix:
  • Add `sidebarOpen: boolean` to HeaderProps and destructure it
  • Pass it from MainLayout (where the state lives) into <Header />
  • Drop the unused searchQuery/onSearchChange props that no longer
    flowed anywhere (search state is owned by useSearchStore)
  • Clean up the unused imports the lint-staged hook caught while we
    were touching these files (Settings, RotateCcw, getRoleLabel,
    BackButton, isMockupGenerator, hasCompletedTour, etc.)

https://claude.ai/code/session_01CUVPfuj5W2dNtPNPAL7iA7

* chore(tests): satisfy lint baseline gate (consistent-type-imports, no-explicit-any)

Two test files that the Lovable bot recently touched introduced new
ESLint baseline regressions which started blocking the pre-push hook
on unrelated branches:

- src/contexts/AuthContext.test.tsx: `import()` type annotation
  forbidden by @typescript-eslint/consistent-type-imports. Hoisted the
  type-only import to the top of the file and reused via typeof.
- src/tests/AdminLayout.test.tsx: explicit `any` on a mock callback.
  Tightened to the actual callback shape vi.fn() expects.

These are surgical lint-only fixes in tests; no runtime behaviour
changes.

https://claude.ai/code/session_01CUVPfuj5W2dNtPNPAL7iA7

---------

Co-authored-by: Claude <noreply@anthropic.com>
@adm01-debug adm01-debug deleted the claude/fix-header-sidebar-open-prop branch May 23, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants