The playground Save button stays enabled after switching to an example, and the save is lost on reload
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
Direzione di ricerca
Leggi apps/playground/src/components/Header/SaveButton/SaveButton.tsx e il test unitario specificato in apps/playground/src/components/Header/SaveButton/__tests__/SaveButton.test.ts; l’issue indica anche la specifica E2E in testing/src/specs/playground.spec.ts. Inizia verificando in che modo la categoria di strumento selezionata influisce sullo stato disabilitato del pulsante, quindi esegui i test unitari e E2E. Il lavoro è completato quando Save rimane disabilitato dopo il passaggio a esempi e modelli.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The playground's Save button stays enabled after switching from a saved instrument with unsaved changes to an example or template, and anything "saved" there is lost on reload. SaveButton recalculates disabled only while the selected instrument's category is Saved. When the user switches away from a dirty saved instrument, the last value, false, is kept. Save is then enabled on an instrument that cannot be saved. Clicking it writes the edits into the in-memory example through updateSelectedInstrument. The store's merge drops every non-Saved instrument on load, so after a reload the example is back to its original code, even though the click gave every sign of success. The button also stays enabled after the click.
Where
apps/playground/src/components/Header/SaveButton/SaveButton.tsx:13-22:
const [disabled, setDisabled] = useState(true);
const editorFiles = useFilesRef();
const selectedInstrument = useAppStore((store) => store.selectedInstrument);
const updateSelectedInstrument = useAppStore((store) => store.updateSelectedInstrument);
useInterval(() => {
if (selectedInstrument.category === 'Saved') {
setDisabled(isEqual(editorFiles.current, selectedInstrument.files));
}
}, 1000);
Reproduce
- Click Create New Instrument and save it as
Mine, then changeindex.ts. Save becomes enabled within a second. - Without saving, select Form Reference in the instrument selector.
- Change Form Reference's
index.ts, click Save, and reload.
Actual: Save is enabled on Form Reference, the click appears to save, and after the reload Form Reference is back to its original code.
Expected: Save is disabled whenever the selected instrument is an example or a template.
Tests
Extract the condition into a helper next to the component and test it in apps/playground/src/components/Header/SaveButton/__tests__/SaveButton.test.ts: it('should disable saving for examples and templates, so a save that cannot persist is never offered').
E2E in testing/src/specs/playground.spec.ts: follow the steps above and assert that the Save button is disabled after switching to Form Reference.
Suggested fix
Recalculate on every tick: setDisabled(selectedInstrument.category !== 'Saved' || isEqual(editorFiles.current, selectedInstrument.files)).
- Lingua principale
- TypeScript
- Stelle
- 119
- Fork
- 19
- Merge medio
- 1g 4h
- PR unite (30g)
- 44
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DouglasNeuroInformatics/OpenDataCapture
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
DouglasNeuroInformatics/OpenDataCapture#1813 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
DouglasNeuroInformatics/OpenDataCapture#1812 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Playground Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DouglasNeuroInformatics/OpenDataCapture#1805 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
DouglasNeuroInformatics/OpenDataCapture#1801 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DouglasNeuroInformatics/OpenDataCapture#1800 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di DouglasNeuroInformatics/OpenDataCapture
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
TomerAberbach/profiler-md#733 ·
I maintainer di solito rispondono entro 1 giorno
-
bug priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
brentspine/brents-toasts#143 ·
-
🐛 bug 🗺️ DB Models & Ops
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
LibreChat-AI/LibreChat#17214 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
Wavvon/Wavvon-clients#136 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
umami-software/umami#4637 ·
I maintainer di solito rispondono entro 3 giorni