mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 14:20:38 +08:00
feat(outline-view): Auto-expand when drag is over item with children #2084
This commit is contained in:
parent
a08eb3e175
commit
7976ec6e0e
1 changed files with 10 additions and 0 deletions
|
@ -136,6 +136,7 @@ class OutlineViewItem extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this._expandTimeout = null;
|
||||||
this.state = {
|
this.state = {
|
||||||
isDropping: false,
|
isDropping: false,
|
||||||
editing: props.item.editing || false,
|
editing: props.item.editing || false,
|
||||||
|
@ -160,6 +161,7 @@ class OutlineViewItem extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
clearTimeout(this._expandTimeout);
|
||||||
if (this._shouldShowContextMenu()) {
|
if (this._shouldShowContextMenu()) {
|
||||||
ReactDOM.findDOMNode(this).removeEventListener('contextmenu', this._onShowContextMenu);
|
ReactDOM.findDOMNode(this).removeEventListener('contextmenu', this._onShowContextMenu);
|
||||||
}
|
}
|
||||||
|
@ -196,6 +198,14 @@ class OutlineViewItem extends Component {
|
||||||
|
|
||||||
_onDragStateChange = ({isDropping})=> {
|
_onDragStateChange = ({isDropping})=> {
|
||||||
this.setState({isDropping});
|
this.setState({isDropping});
|
||||||
|
|
||||||
|
const {item} = this.props;
|
||||||
|
if ((isDropping === true) && (item.children.length > 0) && (item.collapsed)) {
|
||||||
|
this._expandTimeout = setTimeout(this._onCollapseToggled, 650);
|
||||||
|
} else if (isDropping === false && this._expandTimeout) {
|
||||||
|
clearTimeout(this._expandTimeout);
|
||||||
|
this._expandTimeout = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_onDrop = (event)=> {
|
_onDrop = (event)=> {
|
||||||
|
|
Loading…
Reference in a new issue