-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug where clicking "File > New" doesn't open a new sketch #2590
Conversation
Thanks so much for working on this!! :) After looking at this locally, I noticed a few minor differences between the current and updated behavior when clicking "File > New". The first is I have to click the Alert message twice in order to create a new sketch. The second one is once the sketch is created, the "Opened New Sketch" toast message doesn't seem to appear. (Also attaching videos of them below.) Current State: current_state.movUpdated Changes: updated_changes.movBesides these two, I think it seems to overall work for me! I was wondering if this was something that's happening for you as well? |
@raclim Thanks for finding those problems, I will look into it more. I hadn't tried clicking it with unsaved changes. |
This one I am experiencing too.
I'm not experiencing this, I'm seeing the toast. p5.js-web-editor/client/modules/IDE/hooks/useSketchActions.js Lines 24 to 32 in a1a5efd
p5.js-web-editor/client/modules/IDE/pages/IDEView.jsx Lines 44 to 67 in a1a5efd
Ok so I understand why the alert is happening twice. I have to think about which one is the "right" place and which is the extra. I may need to explain more later what the pros and cons of various fixes would be. We call this If I click "ok" on the first alert but then "cancel" on the second alert then it keeps me on the current project but it loses the unsaved changes 🙃 . That leads me to thinking that that first alert is the "right" one. However there are cases where we need the the alert on URL change, so that's the part that I need to think through. |
BTW, we don't get the double alert with the There is a hacky fix I can do which I don't really love but it should work. In the |
@raclim I realized that we lost the code which shows the alert when you try to close the entire window. 😭 Not sure if I should add that in here or make a new PR? p5.js-web-editor/client/modules/IDE/pages/IDEView.jsx Lines 94 to 95 in d26d062
This was something that @dewanshDT and I discussed and I wrote a code to handle it using react-router v6 syntax. But then we ended up staying on v5 and I guess it got lost in the shuffle. I don't think either of us wrote a function component v5 version. Here is some of our discussion and the v6 code:
|
Oooo thanks for catching this! I think this would make sense in a separate issue/PR. Ideally it would be great to get it in the next release, but no rush there!
Although it doesn't feel ideal I think this might be okay for now, and can be revisited! I'm going to merge this in for now! |
Fixes #2584
Changes:
setTimeout
from the URL change in thenewProject
Redux action.Explanation of why this fixes it.
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123