Skip to content
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

Cannot get full path of JSON Key when using react-json-tree #1546

Open
mcnaveen opened this issue Nov 22, 2023 · 0 comments
Open

Cannot get full path of JSON Key when using react-json-tree #1546

mcnaveen opened this issue Nov 22, 2023 · 0 comments

Comments

@mcnaveen
Copy link

onDragStart callback in the valueRenderer props is not returning the full path of the json key.

For example:

  • when dragging the value "Electronics products" it should return something like this x.data[0].description but it just returns "description"

I'm not sure how to change this. I also created a stackblitz sandbox for you to test.

https://stackblitz.com/edit/stackblitz-starters-z1cita?file=src%2Fcomponents%2FViewer.jsx

valueRenderer={(raw, value, key) => (
  <span
    draggable={true}
    onDragStart={(e) => {
      const updatedNamespace =
        selected.namespace.length > 0
          ? [...selected.namespace, key]
          : [key];
      const fullPath = updatedNamespace.join('.');
      e.dataTransfer.setData('text/plain', fullPath);
      e.dataTransfer.setDragImage(document.createElement('span'), 0, 0);
    }}
  >
    {raw}
  </span>
)}
2023-11-22.15-43-22.mp4
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

1 participant