-
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
ElFinder inside a <form> reloads the entire page when pressing and and clicking on buttons #3676
Comments
This issue is stale because it has been open for 50 days with no activity. |
Please keep this issue open. |
This issue is stale because it has been open for 50 days with no activity. |
Please keep this issue open. |
This issue is stale because it has been open for 50 days with no activity. |
Please keep this issue open. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
This was once mentioned in #3184, but I'd consider it a bug (and one that is not hard to fix, see below).
When ElFinder is used within a
<form>
component, clicking on any button (such as in the resize dialog) or pressing enter in an input field (such as the search bar) submits the form, causing the current page to unload. This makes ElFinder unusable. Some frameworks / UI libraries require the use form<form>
and as such, make it hard to integrate / use ElFinder.To Reproduce
For buttons:
$("#elfinder").wrap("<form>")
Writable volume group
->Img + Txt Only
->New folder
code.png
, click onResize & Scale
Crop
tab and click on the aspect ratio lock button (with the lock icon, next to the width / height)For input fields:
$("#elfinder").wrap("<form>")
Expected behavior
The page does not reload, the is is not asked for confirmation whether they wish to leave the page.
Suggested solution
On a technical level, the solution to both issues is simple:
event.preventDefault
.<button type="submit" class="Hidden" onclick="return false;" />
at the start of a<form>
. This can already be done by users, so I would not consider this part too important.type="button"
to the<button>
elements, this will prevent the submission. By default, the type attribute defaults to submit, which I would argue is not correct.event.stopPropagation
, which makes it hard to register custom event listeners that callevent.preventDefault
. It's possible to use the capturing phase instead, but it's still a hack.Screenshots
Screencast.from.2024-10-09.20-43-09.webm
Screencast.from.2024-10-09.20-44-16.webm
The text was updated successfully, but these errors were encountered: