Skip to content
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 : Unable to Create Files or Folders Through the File Actions Modal #3343

Merged
merged 3 commits into from
Feb 20, 2025

Conversation

lakshay-jainn
Copy link
Contributor

Fixes #3329

PROBLEM:
The problem that was occurring was when clicking on Add button in Sidebar -> and then TOUCH CLICKING "Add new file"/ "Add new folder" USING TOUCHPAD . The modal for creating new file or folder was not popping up.

When interacting with a button, events fire in this order:
onMouseDown → onMouseUp → onClick → onBlur

When we Click using mouse :- It directly triggers Onclick
When we use Touch: it triggers onTouchStart and onTouchEnd, which then polyfill to onClick.
But When we TOUCH CLICK USING MOUSEPAD: it triggers onMouseDown.

The default behavior of onMouseDown is to shift focus as soon as possible.
It doesn't wait for onClick to occur.
Therefore directly executing onBlur.
And hence not opening the modal.

SOLUTION:
The most appropriate solution to this problem i found was:-
onMouseDown={(e) => e.preventDefault()}
Basically, this removes the default focus shifting behavior of onMouseDown.
And, 'waits' for onClick to execute.
After which, onBlur is executed.
Therefore, it now adds a file or folder when Touch Clicking using touchpad.

Solution executed in file:-
In p5.js-web-editor\client\modules\IDE\components\Sidebar.jsx

I have verified that this pull request:

  • [ ✔] has no linting errors (npm run lint)
  • [✔ ] has no test errors (npm run test)
  • [✔ ] is from a uniquely-named feature branch and is up to date with the develop branch.
  • [✔] is descriptively named and links to an issue number, i.e. Fixes #123

Copy link

welcome bot commented Feb 15, 2025

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already.

Copy link

release-com bot commented Feb 15, 2025

Release Environments

This Environment is provided by Release, learn more!
To see the status of the Environment click on Environment Status below.

🔧Environment Status : https://app.release.com/public/Processing%20Foundation/env-e027732142

@Jatin24062005
Copy link
Contributor

@lakshay-jainn Hey, I went through your Pull Request, and it looks like it’s working now. However, could you please add the same line of code to the button below, which appears when the user is authenticated? This will ensure the fix applies to each sidebar button. Additionally, this will help the maintainers review the changes more quickly. Thank You for working on these.

@lakshay-jainn
Copy link
Contributor Author

@Jatin24062005 hello , sorry i didn't look the third button as i wasn't logged in. I added this fix for that upload button too. Thank you for quick reply.

@lakshay-jainn lakshay-jainn mentioned this pull request Feb 15, 2025
4 tasks
Copy link
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @lakshay-jainn for working on this and @Jatin24062005 for reviewing and confirming the fix!

Although I still haven't been able to recreate the issue myself, I think what's going on in the file so far makes sense to me. I went ahead with removing a a few comments that I felt were self-explanatory. I'm going to merge this in, but please feel free to follow up with any additional thoughts or other PRs, thanks!

@raclim raclim merged commit 3094040 into processing:develop Feb 20, 2025
1 check passed
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.

Unable to Create Files or Folders Through the File Actions Modal
3 participants