This repository was archived by the owner on Jun 10, 2026. It is now read-only.
fix: don't clear list when CSV import column prompt is cancelled#10080
Open
Chessing234 wants to merge 1 commit into
Open
fix: don't clear list when CSV import column prompt is cancelled#10080Chessing234 wants to merge 1 commit into
Chessing234 wants to merge 1 commit into
Conversation
When importing a multi-column CSV into a list, the user is asked which column to use via window.prompt. Pressing Cancel returns null, so parseInt(null, 10) is NaN and every row[NaN - 1] is undefined; the subsequent filter drops them all, leaving an empty list value that overwrites the existing contents. Bail out of the import when the prompt is cancelled so the list is left unchanged. Fixes scratchfoundation#7313
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Resolves
Resolves #7313
Proposed Changes
When importing a multi-column
.csv/.tsvinto a list,Monitor'shandleImportasks which column to use withwindow.prompt. The return value was passed straight intoparseInt(...):If the user presses Cancel,
promptreturnsnull, soparseInt(null, 10)isNaN. Everyrow[NaN - 1]is thenundefined, the.filter(item => typeof item === 'string')drops them all, and the list is overwritten with an empty array — silently deleting the list's existing contents.This change reads the prompt response first and returns early when it is
null, leaving the list untouched on cancel. Entering a valid column still works exactly as before.Reason for Changes
Pressing Cancel should abort the import without changing the project, as described in the issue. The old code treated a cancelled prompt as "import an empty column," which wiped the list (High Severity data loss).
Test Coverage
Added
test/unit/containers/monitor.test.jsxwith two cases:prompt→null) does not callsetVariableValue, so the list is unchanged;prompt→'2') imports that column (['a2', 'b2']).The first test fails on the current
masterand passes with this change; the second guards against regressing normal imports.npm run test:unit -- test/unit/containers/monitor.test.jsxpasses andeslint . --ext .js,.jsxis clean.