Repository navigation
fix(negocios): edit form now pre-fills data with forced remount - #8
Merged
Merged
Conversation
- Add key={negocioEditData?.id || 'new'} to NegocioForm in /clientes.
The form component persists while selectedCliente is open, so without
a key change React reused the instance and useState kept stale values.
This caused the edit form to open empty even when a negocio had data.
- Add regression E2E test that opens create form first, then edits two
different negocios, verifying each loads its own data.
Verification:
- npx tsc --noEmit ✅
- npm run test -- --run ✅ 1836 passed
- npx playwright test e2e/negocios-crud.spec.ts --project=chromium ✅ 8 passed
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
casasleonj
added a commit
that referenced
this pull request
Aug 31, 2026
…a modal' (AGENTS.md #8) El selector 'button:has-text("Crear")' global matcheaba el '+ Crear Embarque' del EmptyState detrás del modal → click interceptado. Ahora todo scopeado a [role=dialog] + assert end-to-end sobre el botón de stock del header (sin depender del timing del toast). 6/6 con --repeat-each=3. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This branch was successfully deployed
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.
Bug
Al hacer click en Editar un negocio desde
/clientes, el modal se abría vacío — todos los campos mostraban placeholders. El usuario no veía qué información iba a editar.Root cause
NegocioFormse renderiza siempre que hay unselectedClienteabierto, no solo cuando el modal está abierto. Al cerrar y volver a abrir, React reutilizaba la misma instancia del componente.useStatesolo inicializa coneditDataen el primer mount, por lo que al cambiar de negocio (o de crear a editar) los campos quedaban vacíos/stale.Fix
Se agregó
key={negocioEditData?.id || 'new'}alNegocioForm. Esto fuerza un remount cada vez que cambia el negocio a editar (o se pasa a modo crear), asegurando queuseStatese inicialice con los datos correctos.Regression test
Nuevo test en
e2e/negocios-crud.spec.ts:Verification
npx tsc --noEmit✅npm run test -- --run✅ 1836 passednpx playwright test e2e/negocios-crud.spec.ts --project=chromium✅ 8 passedFiles changed
src/app/(app)/clientes/clientes-client/index.tsxe2e/negocios-crud.spec.ts