Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

File drop UI fixes and improvements #5505

Merged
merged 37 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
89bc443
Fix file drop UI
SimonBrandner Dec 16, 2020
41e2ffd
Added background
SimonBrandner Dec 16, 2020
da97d18
Added a comment
SimonBrandner Dec 16, 2020
dcb30b7
Fix left panel resizer
SimonBrandner Dec 17, 2020
e70dee0
Fix flickering
SimonBrandner Dec 17, 2020
044e02b
Remove spaces in empty line
SimonBrandner Dec 17, 2020
bebbb3b
Merge branch 'develop' into improve-file-drop-ui
SimonBrandner Dec 17, 2020
365d252
Fix removing event listeners
SimonBrandner Dec 17, 2020
5d7e45e
Added dragCounter
SimonBrandner Dec 17, 2020
c1a105f
Merge branch 'develop' into improve-file-drop-ui
SimonBrandner Feb 25, 2021
ad85764
Fix timeline expansion
SimonBrandner Feb 25, 2021
aa4ec9f
Make $droptarget-bg-color more opaque
SimonBrandner Feb 25, 2021
8551855
Add $droptarget-bg-color to the dark theme
SimonBrandner Feb 25, 2021
a3001f7
Remove rounded corners of the drop area
SimonBrandner Feb 25, 2021
26b70b6
Remove label background
SimonBrandner Feb 25, 2021
6a7340e
Use new upload icon
SimonBrandner Feb 25, 2021
1c48804
Remove unnecessary class
SimonBrandner Feb 25, 2021
43e1144
Don't use TintableSVG
SimonBrandner Feb 25, 2021
7277c28
Fix weird crash
SimonBrandner Feb 25, 2021
49ea9a4
Remove sdk import
SimonBrandner Feb 25, 2021
1a7f909
Animate icon size
SimonBrandner Feb 26, 2021
f0c2684
Fix formatting
SimonBrandner Feb 26, 2021
172cc01
Add background animation
SimonBrandner Feb 26, 2021
3e0558f
Remove droptarget colors
SimonBrandner Feb 26, 2021
49ea83e
i18n
SimonBrandner Feb 26, 2021
e90ae2e
Delint
SimonBrandner Feb 26, 2021
819a0b0
min-width
SimonBrandner Feb 26, 2021
0d6a9fc
Remove weird styling
SimonBrandner Feb 26, 2021
11c5aa0
Remove mx_RoomView_container
SimonBrandner Feb 26, 2021
9a5ba07
Fix auxPanel
SimonBrandner Feb 26, 2021
3bed374
Remove unnecessary code
SimonBrandner Feb 26, 2021
3a643e5
Remove unnecessary changes
SimonBrandner Feb 26, 2021
ebedd3c
Remove space
SimonBrandner Mar 2, 2021
ff00683
Use ===
SimonBrandner Mar 2, 2021
0a4c0b6
Move fileDropTarget to RoomView
SimonBrandner Mar 2, 2021
4476843
Remove unused _t
SimonBrandner Mar 2, 2021
831cc7e
i18n
SimonBrandner Mar 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions res/css/structures/_MainSplit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,30 @@ limitations under the License.
}

.mx_MainSplit > .mx_RightPanel_ResizeWrapper {
padding: 5px;
// margin left to not allow the handle to not encroach on the space for the scrollbar
margin-left: 8px;
padding: 0 5px 5px 0px;
height: calc(100vh - 51px); // height of .mx_RoomHeader.light-panel

.mx_RightPanel_ResizeHandle {
width: 9px;
}

&:hover .mx_RightPanel_ResizeHandle {
// Need to use important to override element style attributes
// set by re-resizable
top: 50% !important;
transform: translate(0, -50%);
&::before {
position: absolute;
left: 6px;
top: 50%;
transform: translate(0, -50%);

height: 64px;
width: 4px;
border-radius: 4px;

content: ' ';

height: 64px !important; // to match width of the ones on roomlist
width: 4px !important;
border-radius: 4px !important;
background-color: $primary-fg-color;
opacity: 0.8;

background-color: $primary-fg-color;
opacity: 0.8;
margin-left: -10px;
}
}
}
32 changes: 20 additions & 12 deletions res/css/structures/_RoomView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,33 @@ limitations under the License.
.mx_RoomView_fileDropTarget {
min-width: 0px;
width: 100%;
height: 100%;

font-size: $font-18px;
text-align: center;

pointer-events: none;

padding-left: 12px;
padding-right: 12px;
margin-left: -12px;

border-top-left-radius: 10px;
border-top-right-radius: 10px;

background-color: $droptarget-bg-color;
border: 2px #e1dddd solid;
border-bottom: none;

position: absolute;
top: 52px;
bottom: 0px;
z-index: 3000;

display: flex;
justify-content: center;
align-items: center;
}

.mx_RoomView_fileDropTargetLabel {
top: 50%;
width: 100%;
margin-top: -50px;
position: absolute;

border-radius: 10px;
padding: 10px;

background-color: $menu-bg-color;
}

.mx_RoomView_auxPanel {
Expand Down Expand Up @@ -116,16 +117,23 @@ limitations under the License.
height: 50px;
}

.mx_RoomView_body {
.mx_RoomView_container {
position: relative; //for .mx_RoomView_auxPanel_fullHeight
display: flex;
flex-direction: column;
}

.mx_RoomView_body {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;

.mx_RoomView_messagePanel, .mx_RoomView_messagePanelSpinner, .mx_RoomView_messagePanelSearchSpinner {
order: 2;
}

margin-right: 10px;
}

.mx_RoomView_body .mx_RoomView_timeline {
Expand Down
74 changes: 50 additions & 24 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export interface IState {
rejecting?: boolean;
rejectError?: Error;
hasPinnedWidgets?: boolean;
dragCounter: number;
}

export default class RoomView extends React.Component<IProps, IState> {
Expand Down Expand Up @@ -237,6 +238,7 @@ export default class RoomView extends React.Component<IProps, IState> {
canReply: false,
useIRCLayout: SettingsStore.getValue("useIRCLayout"),
matrixClientIsReady: this.context && this.context.isInitialSyncComplete(),
dragCounter: 0,
};

this.dispatcherRef = dis.register(this.onAction);
Expand Down Expand Up @@ -525,8 +527,8 @@ export default class RoomView extends React.Component<IProps, IState> {
if (!roomView.ondrop) {
roomView.addEventListener('drop', this.onDrop);
roomView.addEventListener('dragover', this.onDragOver);
roomView.addEventListener('dragleave', this.onDragLeaveOrEnd);
roomView.addEventListener('dragend', this.onDragLeaveOrEnd);
roomView.addEventListener('dragenter', this.onDragEnter);
roomView.addEventListener('dragleave', this.onDragLeave);
}
}

Expand Down Expand Up @@ -570,8 +572,8 @@ export default class RoomView extends React.Component<IProps, IState> {
const roomView = this.roomView.current;
roomView.removeEventListener('drop', this.onDrop);
roomView.removeEventListener('dragover', this.onDragOver);
roomView.removeEventListener('dragleave', this.onDragLeaveOrEnd);
roomView.removeEventListener('dragend', this.onDragLeaveOrEnd);
roomView.removeEventListener('dragenter', this.onDragEnter);
roomView.removeEventListener('dragleave', this.onDragLeave);
}
dis.unregister(this.dispatcherRef);
if (this.context) {
Expand Down Expand Up @@ -1108,14 +1110,38 @@ export default class RoomView extends React.Component<IProps, IState> {
this.updateTopUnreadMessagesBar();
};

private onDragEnter = ev => {
ev.stopPropagation();
ev.preventDefault();

this.setState({
dragCounter: this.state.dragCounter + 1,
draggingFile: true,
});
};

private onDragLeave = ev => {
ev.stopPropagation();
ev.preventDefault();

this.setState({
dragCounter: this.state.dragCounter - 1,
});

if (this.state.dragCounter == 0) {
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
this.setState({
draggingFile: false,
});
}
};

private onDragOver = ev => {
ev.stopPropagation();
ev.preventDefault();

ev.dataTransfer.dropEffect = 'none';

if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) {
this.setState({ draggingFile: true });
ev.dataTransfer.dropEffect = 'copy';
}
};
Expand All @@ -1126,14 +1152,12 @@ export default class RoomView extends React.Component<IProps, IState> {
ContentMessages.sharedInstance().sendContentListToRoom(
ev.dataTransfer.files, this.state.room.roomId, this.context,
);
this.setState({ draggingFile: false });
dis.fire(Action.FocusComposer);
};

private onDragLeaveOrEnd = ev => {
ev.stopPropagation();
ev.preventDefault();
this.setState({ draggingFile: false });
this.setState({
draggingFile: false,
dragCounter: this.state.dragCounter - 1,
});
};

private injectSticker(url, info, text) {
Expand Down Expand Up @@ -2003,22 +2027,24 @@ export default class RoomView extends React.Component<IProps, IState> {
appsShown={this.state.showApps}
/>
<MainSplit panel={rightPanel} resizeNotifier={this.props.resizeNotifier}>
<div className="mx_RoomView_body">
<div className={"mx_RoomView_container"}>
{auxPanel}
<div className={timelineClasses}>
{topUnreadMessagesBar}
{jumpToBottom}
{messagePanel}
{searchResultsPanel}
</div>
<div className={statusBarAreaClass}>
<div className="mx_RoomView_statusAreaBox">
<div className="mx_RoomView_statusAreaBox_line" />
{statusBar}
<div className="mx_RoomView_body">
<div className={timelineClasses}>
{topUnreadMessagesBar}
{jumpToBottom}
{messagePanel}
{searchResultsPanel}
</div>
<div className={statusBarAreaClass}>
<div className="mx_RoomView_statusAreaBox">
<div className="mx_RoomView_statusAreaBox_line" />
{statusBar}
</div>
</div>
{previewBar}
{messageComposer}
</div>
{previewBar}
{messageComposer}
</div>
</MainSplit>
</ErrorBoundary>
Expand Down
1 change: 1 addition & 0 deletions src/contexts/RoomContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const RoomContext = createContext<IState>({
canReply: false,
useIRCLayout: false,
matrixClientIsReady: false,
dragCounter: 0,
Copy link
Contributor Author

@SimonBrandner SimonBrandner Dec 17, 2020

Choose a reason for hiding this comment

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

This is probably not necessary here? But there is draggingFile: false, is that intentional?

Copy link
Member

Choose a reason for hiding this comment

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

I'm slightly worried that counting enters/leaves will cause problems and desync (there's a ton of ways to leave a browser window without triggering a dragleave event, making you always +1)

Can we get away with a simple isDragging instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is the only solution I've found... I don't think I quite understand what you mean by isDragging here. There seems to be a isDragging method in react-dnd but I don't think this can be used here. What am I missing?

});
RoomContext.displayName = "RoomContext";
export default RoomContext;