Renaming a folder doubles the folder name in file paths (console errors show /lib/lib/helper.js)
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, redux
- Domain
- frontend
Research direction
The bug is in the UPDATE_FILE_NAME case of client/modules/IDE/reducers/files.js, where the children loop passes action.id to setFilePath instead of childId. Read that case and the setFilePath helper, then add reducer tests for top-level and nested folder renames in files.test.js, which currently only cover deletion. Done when renaming folder js to lib gives children paths like /lib/helper.js and the new tests pass.
Written by the indexing model from the issue text.
Description
p5.js version
2.3.4
What is your operating system?
Mac OS
Web browser and version
155.0.8059.40 (Official Build) (arm64)
Actual Behavior
After renaming a folder in the sidebar, the editor stores a wrong path for the
folder and every file inside it: the folder's own name is added twice. This shows
up in console errors. A script in a renamed folder lib reports its error at
/lib/lib/helper.js:1:1 instead of /lib/helper.js:1:1
When logged in, the wrong path only lasts until the next save (each save rebuilds
the paths). When logged out, nothing is saved to the server, so it stays wrong for
the whole session.
Cause: in client/modules/IDE/reducers/files.js, the UPDATE_FILE_NAME case loops
over the folder's children but passes action.id (the folder itself) instead of
childId to setFilePath:
updatedFile.children.forEach((childId) => {
setFilePath(newState, action.id, childPath);
});
Expected Behavior
After renaming folder js to lib, files inside it should have the path
/lib/..., and the console should show at /lib/helper.js:1:1.
Steps to reproduce
- Open editor.p5js.org while logged out.
- Create a folder
js, and inside it a filehelper.jscontainingnoSuchFunction(); - In index.html, add
<script src="js/helper.js"></script>above the sketch.js script tag. - Press Play and expand the error in the console:
at /js/helper.js:1:1(correct). - Rename the folder
jstoliband change the script tag tolib/helper.js. - Press Play and expand the error:
at /lib/lib/helper.js:1:1(wrong).
Suggested fix: pass childId instead of action.id to setFilePath in the
UPDATE_FILE_NAME case. I've tested this locally with unit tests for the reducer
(top-level and nested folder renames); the existing tests in files.test.js only
cover deletion. I'd be happy to open a PR with the fix and tests if this is approved.
Related: #2186 (mutation in the files reducer), a different issue in the same file.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 1.7k
- Avg merge
- 5d 16h
- Merged PRs (30d)
- 8
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from processing/p5.js-web-editor
-
p5 logo is broken on verification emailsPossibly taken @sourabh65mehta claimed this 4 days ago. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
processing/p5.js-web-editor#4364 · 2 comments · 1 assignee ·
Maintainers usually reply within 3 days
-
`PATCH /editor/project/visibility` returns 200 with `null` and doesn't update when `projectId` is a slugMay be free again @Prbhtsgh claimed this 11 days ago, and no pull request is open. OpenAwaiting Maintainer Approval Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
processing/p5.js-web-editor#4348 · 3 comments ·
Maintainers usually reply within 3 days
-
Fix: example.js stores defaultHTML function reference instead of calling it, causing examples to display raw JavaScript source in previewMay be free again @syedbarkath980 claimed this 15 days ago, and no pull request is open. OpenAwaiting Maintainer Approval Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
processing/p5.js-web-editor#4344 · 1 comment ·
Maintainers usually reply within 3 days
-
signup form gets stuck when signup request fails due to network errorPossibly taken @PS01K claimed this 45 days ago. OpenAwaiting Maintainer Approval Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
processing/p5.js-web-editor#4285 · 3 comments ·
Maintainers usually reply within 3 days
-
Enhancement: Memoize sketches list and pagination selectors in SketchList.jsx to prevent redundant rendering cyclesPossibly taken @nodeanurag claimed this 3 days ago. OpenEnhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
processing/p5.js-web-editor#4270 · 2 comments · 1 assignee ·
Maintainers usually reply within 3 days
All issues in processing/p5.js-web-editor
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarperFast/harper#3299 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
osmlab/name-suggestion-index#12992 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
open-government-design-system/ogds-elements#199 ·
Maintainers usually reply within 1 day
-
area:plugin type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Document annotations cannot anchor visible code after a shorter or different fenced-code markerOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
paperclipai/paperclip#16898 ·
Maintainers usually reply within 1 day