Skip to content

Expected to find a valid target. #857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sinanyaman95 opened this issue Jan 18, 2021 · 5 comments
Closed

Expected to find a valid target. #857

sinanyaman95 opened this issue Jan 18, 2021 · 5 comments

Comments

@sinanyaman95
Copy link

sinanyaman95 commented Jan 18, 2021

This is reproducible by simply using the Tree-to-tree dragging example in development mode.

How: Select a node to copy/move to the last position of another tree and drag it a little bit more under that.
Reason: It is looking for a targetId which is not there. If the last valid target id is T3, this will cause the dnd to look for a targetId of T5, which is not there. DragDropMonitorImpl.js is where I debugged this.
Example:
SortableError

Source Code:

import React, { Component } from 'react';
import SortableTree from 'react-sortable-tree';
// In your own app, you would need to use import styles once in the app
// import 'react-sortable-tree/styles.css';

class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      treeData1: [
        { title: 'node1', children: [{ title: 'node 1.1' }] },
        { title: 'node2' },
      ],
      treeData2: [{ title: 'node3' }],
      shouldCopyOnOutsideDrop: false,
    };
  }

  render() {
    // Both trees need to share this same node type in their
    // `dndType` prop
    const externalNodeType = 'yourNodeType';
    const { shouldCopyOnOutsideDrop } = this.state;
    return (
      <div>
        <div
          style={{
            height: 350,
            width: 350,
            float: 'left',
            border: 'solid black 1px',
          }}
        >
          <SortableTree
            treeData={this.state.treeData1}
            onChange={treeData1 => this.setState({ treeData1 })}
            dndType={externalNodeType}
            shouldCopyOnOutsideDrop={shouldCopyOnOutsideDrop}
          />
        </div>

        <div
          style={{
            height: 350,
            width: 350,
            float: 'left',
            border: 'solid black 1px',
          }}
        >
          <SortableTree
            treeData={this.state.treeData2}
            onChange={treeData2 => this.setState({ treeData2 })}
            dndType={externalNodeType}
            shouldCopyOnOutsideDrop={shouldCopyOnOutsideDrop}
          />
        </div>

        <div style={{ clear: 'both' }} />

        <div>
          <label htmlFor="should-copy" style={{ fontSize: '0.8rem' }}>
            Enable node copy via <b>shouldCopyOnOutsideDrop</b>:
            <input
              type="checkbox"
              id="should-copy"
              value={shouldCopyOnOutsideDrop}
              onChange={event =>
                this.setState({
                  shouldCopyOnOutsideDrop: event.target.checked,
                })
              }
            />
          </label>
        </div>
      </div>
    );
  }
}

export default App;
@pasieronen
Copy link

There's an open PR #740 that should fix this.

@sinanyaman95
Copy link
Author

nice, thanks!

@relferreira
Copy link

It seems that this PR was not merged and I'm with the same problem 😢

@iamtofr
Copy link

iamtofr commented Jun 17, 2021

yes same here

@sinanyaman95
Copy link
Author

I am no longer using this library, but I had figured out that this error is only visible in development mode. No such error in production mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants