Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

The playground Save button stays enabled after switching to an example, and the save is lost on reload

Aperta Adatta ai principianti
#1,754 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Ambito
frontend, testing

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

Area: Playground Bug Difficulty: Low Good First Issue Priority: Low

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

  1. Click Create New Instrument and save it as Mine, then change index.ts. Save becomes enabled within a second.
  2. Without saving, select Form Reference in the instrument selector.
  3. 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DouglasNeuroInformatics/OpenDataCapture

Tutte le issue di DouglasNeuroInformatics/OpenDataCapture

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.