Skip to content

Fix backup import from file#3491

Open
martinsbruveris wants to merge 1 commit into
IvarK:masterfrom
martinsbruveris:fix/backup-import-bug
Open

Fix backup import from file#3491
martinsbruveris wants to merge 1 commit into
IvarK:masterfrom
martinsbruveris:fix/backup-import-bug

Conversation

@martinsbruveris

Copy link
Copy Markdown

I came across a bug with in the Backup Saves modal. Basically, the "Import Saves" button was not working. I asked Claude to diagnose the issue, and Claude found to problems: first, there was a CSS issue that led to the file selection window not being opened; and there was a second independent issue, that led to game state not being updated, even after the file was loaded.

The fix is simple and I verified locally that it works.

For reference, below is the analysis done by Claude: The "Import from file" button in the Automatic Backup Saves modal was broken in two independent ways:

  1. UI: the button never opened a file picker. The invisible .c-file-import input is position: absolute and relies on a position: relative wrapper (.c-file-import-button) to be anchored over the button, exactly as the working import in OptionsSavingTab.vue does. The backup modal's PrimaryButton omitted that class, so the invisible input was positioned elsewhere and clicks on the button never reached it (and the <label for="file"> has no matching element). Add c-file-import-button to anchor the input over the button.

  2. Logic: importBackupsFromFile wrote the per-slot times to this.backupTimeData, a property that exists nowhere else; the field read by the modal, resetBackupTimer(), and the backup logic is this.lastBackupTimes. The imported backups were persisted to localStorage but the in-memory state/UI never refreshed until a reload. Write to this.lastBackupTimes instead.

The "Import from file" button in the Automatic Backup Saves modal was
broken in two independent ways:

1. UI: the button never opened a file picker. The invisible
   `.c-file-import` input is `position: absolute` and relies on a
   `position: relative` wrapper (`.c-file-import-button`) to be anchored
   over the button, exactly as the working import in OptionsSavingTab.vue
   does. The backup modal's PrimaryButton omitted that class, so the
   invisible input was positioned elsewhere and clicks on the button never
   reached it (and the `<label for="file">` has no matching element).
   Add `c-file-import-button` to anchor the input over the button.

2. Logic: importBackupsFromFile wrote the per-slot times to
   `this.backupTimeData`, a property that exists nowhere else; the field
   read by the modal, resetBackupTimer(), and the backup logic is
   `this.lastBackupTimes`. The imported backups were persisted to
   localStorage but the in-memory state/UI never refreshed until a reload.
   Write to `this.lastBackupTimes` instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant