Skip to content

Conversation

jdamon96
Copy link

@jdamon96 jdamon96 commented Sep 8, 2025

Fixes an issue where the JSON tree would unexpectedly collapse when users drag to select text content within JSON values.

Problem:

  • Users dragging to select text in JSON values would cause the entire tree to collapse on mouse release
  • This occurred because the
      element's click handler (toggleExpand) was triggered by the click event generated at the end of text selection

    Solution:

    • Added intelligent click detection that distinguishes between intentional collapse clicks and clicks resulting from text selection
    • Tracks mouse down/up events and checks for active text selection using window.getSelection()
    • Prevents collapse when:
      • Mouse target changes between down/up (indicating drag)
      • Time between mouse down/up exceeds 200ms (indicating drag)
      • Active text selection is detected

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

Successfully merging this pull request may close these issues.

Highlighting values closes the node
1 participant