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

IBX-8789: Fix double handling of file upload on window d&d #1332

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

tischsoic
Copy link
Contributor

🎫 Issue IBX-8789

Description:

For QA:

Documentation:

@@ -110,6 +110,7 @@ export default class MultiFileUploadModule extends Component {

handleDropOnWindow(event) {
this.preventDefaultAction(event);
event.stopImmediatePropagation();
Copy link
Contributor Author

@tischsoic tischsoic Aug 23, 2024

Choose a reason for hiding this comment

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

Note: MFU is rendered twice in Sub-items, because extraAction items are rendered twice - once in the normal list and once in the popup list. Even though at the given time one of them always is hidden, they are always both rendered.
Because of this we want to prevent one of them from handling file d&d, so that it is handled only by one of them. Regular event.stopPropagation() does not work, because both handlers are attached to the same node thus we need in this case event.stopImmediatePropagation().
ref. https://developer.mozilla.org/en-US/docs/Web/API/Event/stopImmediatePropagation

@tischsoic tischsoic force-pushed the IBX-8789-d-and-d-double-upload-problem branch from a58d047 to 3cfefbe Compare August 28, 2024 13:11
@juskora
Copy link
Contributor

juskora commented Aug 29, 2024

Unfortunately this fix impacts drag and drop on Multi-upload modal, vide recording.
Checked on Exp 4.6.10 tag, 4.6.10-dev.

2024-08-28_14-46-18.mp4

@@ -122,7 +131,7 @@ export default class DropAreaComponent extends Component {
});

return (
<form className="c-drop-area" multiple={true} onDrop={this.handleUpload}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that multiple attribute does nothing and can be deleted.

@@ -122,7 +131,7 @@ export default class DropAreaComponent extends Component {
});

return (
<form className="c-drop-area" multiple={true} onDrop={this.handleUpload}>
<form className="c-drop-area" onDrop={this.handleUpload} ref={this._refForm}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to use standard addEventListener because of how React handles the events, namely React has one event listener on the root instead of individual elements and an event listener from MultiFileUploadModule added with removeEventListener was called before onDrop listener even though onDrop is attached on a deeper node in the DOM.

@tischsoic tischsoic force-pushed the IBX-8789-d-and-d-double-upload-problem branch from e442fcb to 4296f0c Compare September 10, 2024 12:19
Copy link

sonarcloud bot commented Sep 10, 2024

@juskora
Copy link
Contributor

juskora commented Sep 11, 2024

QA Approved on Ibexa DXP Experience 4.6-dev.

@mikadamczyk mikadamczyk merged commit f38637e into 4.6 Sep 11, 2024
28 checks passed
@mikadamczyk mikadamczyk deleted the IBX-8789-d-and-d-double-upload-problem branch September 11, 2024 13:38
@tischsoic
Copy link
Contributor Author

Merged up:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants