Skip to content

Commit f73f97d

Browse files
committed
fix inbox drag drop (keybase#20977)
1 parent f62712e commit f73f97d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

shared/chat/inbox/index.desktop.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const FakeRow = ({idx}) => (
4646

4747
const FakeRemovingRow = () => <Kb.Box2 direction="horizontal" style={styles.fakeRemovingRow} />
4848

49+
const dragKey = '__keybase_inbox'
50+
4951
class Inbox extends React.Component<T.Props, State> {
5052
state = {
5153
dragY: -1,
@@ -109,6 +111,10 @@ class Inbox extends React.Component<T.Props, State> {
109111
return getRowHeight(row.type, row.type === 'divider' && row.showButton)
110112
}
111113

114+
private onDragStart = ev => {
115+
ev.dataTransfer.setData(dragKey, dragKey)
116+
}
117+
112118
private itemRenderer = (index, style) => {
113119
const row = this.props.rows[index]
114120
if (!row) {
@@ -130,7 +136,12 @@ class Inbox extends React.Component<T.Props, State> {
130136
<div style={{...divStyle, position: 'relative'}}>
131137
{row.showButton && (
132138
<>
133-
<Kb.Box className="grabLinesContainer" draggable={row.showButton} style={styles.grabber}>
139+
<Kb.Box
140+
className="grabLinesContainer"
141+
draggable={row.showButton}
142+
onDragStart={this.onDragStart}
143+
style={styles.grabber}
144+
>
134145
<Kb.Box2 className="grabLines" direction="vertical" style={styles.grabberLineContainer}>
135146
<Kb.Box2 direction="horizontal" style={styles.grabberLine} />
136147
<Kb.Box2 direction="horizontal" style={styles.grabberLine} />
@@ -282,7 +293,7 @@ class Inbox extends React.Component<T.Props, State> {
282293
private listChild = ({index, style}) => this.itemRenderer(index, style)
283294

284295
private onDragOver = e => {
285-
if (this.scrollDiv.current) {
296+
if (this.scrollDiv.current && e.dataTransfer.types.length > 0 && e.dataTransfer.types[0] === dragKey) {
286297
this.setState({
287298
dragY:
288299
e.clientY - this.scrollDiv.current.getBoundingClientRect().top + this.scrollDiv.current.scrollTop,

0 commit comments

Comments
 (0)