feat(outline-view): Auto-expand when drag is over item with children #2084

This commit is contained in:
Ben Gotow 2016-05-03 15:17:02 -07:00
parent a08eb3e175
commit 7976ec6e0e

View file

@ -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)=> {