mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-18 07:22:08 +03:00
Merge pull request #5827 from SimonBrandner/show-drop-only-file
Show drop file UI only if dragging a file
This commit is contained in:
commit
cc7982cfca
1 changed files with 13 additions and 4 deletions
|
@ -1137,10 +1137,16 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
this.setState({
|
// We always increment the counter no matter the types, because dragging is
|
||||||
dragCounter: this.state.dragCounter + 1,
|
// still happening. If we didn't, the drag counter would get out of sync.
|
||||||
draggingFile: true,
|
this.setState({dragCounter: this.state.dragCounter + 1});
|
||||||
});
|
|
||||||
|
// See:
|
||||||
|
// https://docs.w3cub.com/dom/datatransfer/types
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file
|
||||||
|
if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) {
|
||||||
|
this.setState({draggingFile: true});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private onDragLeave = ev => {
|
private onDragLeave = ev => {
|
||||||
|
@ -1164,6 +1170,9 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
ev.dataTransfer.dropEffect = 'none';
|
ev.dataTransfer.dropEffect = 'none';
|
||||||
|
|
||||||
|
// See:
|
||||||
|
// https://docs.w3cub.com/dom/datatransfer/types
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file
|
||||||
if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) {
|
if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) {
|
||||||
ev.dataTransfer.dropEffect = 'copy';
|
ev.dataTransfer.dropEffect = 'copy';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue