redux-devtools icon indicating copy to clipboard operation
redux-devtools copied to clipboard

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

Open mcnaveen opened this issue 1 year ago • 0 comments

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>
)}

https://github.com/reduxjs/redux-devtools/assets/8493007/54fc9ac3-4aee-4f23-a8e0-43e82839e478

mcnaveen avatar Nov 22 '23 10:11 mcnaveen