🎪 Live Event Monitor
Interact with the tree to see events in real-time
Interactive Tree
Live Event Log
Event Log
0Event Monitor Guide
🎯 How to Test Events:
- 👆 Click nodes to trigger click events
- 📂 Expand/collapse folders to see expand events
- 🔍 Search to trigger search result events
- 🤏 Drag & drop items to see drag events
- ✅ Select nodes to see selection events
📊 Event Statistics:
Total events captured: 0Log displays last 20 events
Events are captured in real-time
🔥 Core Events
Essential events fired by user interactions
Event Reference
| Event | Trigger | Event Detail | Description | 
|---|---|---|---|
| nodeClick | User click | { id, data, path, level } | Fired when user clicks on any part of a tree node | 
| nodeExpand | Expand/collapse | { id, expanded, children, level } | Fired when a node's expanded state changes | 
| nodeSelect | Selection change | { id, selected, data, path } | Fired when a node's selection state changes | 
| nodeFocus | Keyboard focus | { id, data, previousFocus } | Fired when focus moves to a different node | 
Event Handling Examples
Implementation Guide
🎯 Event Timing
Core events fire immediately when user interactions occur, allowing for real-time response.
📊 Event Detail Structure
All events include consistent data structure with node information, state changes, and context.
🔄 State Management
Use events to sync tree state with your application state management system (Redux, Zustand, etc.).
⚡ Performance Notes
- Events are throttled for high-frequency actions
- Event handlers should be lightweight
- Use event delegation patterns for large trees
🤏 Drag & Drop Events
Events for drag and drop operations with detailed feedback
Drag Event Reference
| Event | Phase | Event Detail | Use Case | 
|---|---|---|---|
| dragStart | Start | { draggedNode, originalIndex } | Initialize drag operation, show UI feedback | 
| dragOver | During | { draggedNode, targetNode, position } | Validate drop target, show drop zones | 
| dragEnter | During | { draggedNode, targetNode } | Highlight valid drop targets | 
| dragLeave | During | { draggedNode, targetNode } | Remove drop target highlights | 
| drop | End | { draggedNode, targetNode, newIndex, position } | Execute the actual move operation | 
| dragEnd | End | { draggedNode, success, canceled } | Clean up drag UI, update state | 
Drag Event Implementation
Drag & Drop Guide
🎯 Drag Operation Flow
- dragStart: User begins dragging
- dragOver/dragEnter: Hovering over targets
- drop: User releases on valid target
- dragEnd: Operation completes
✅ Validation System
Use dragValidationCallback to implement business rules and prevent invalid drops.
🎨 Visual Feedback
Events provide hooks for custom drag indicators, drop zones, and animation feedback.
💾 Data Persistence
The drop event is the ideal place to update your data and sync with backends.
🔍 Search Events
Events fired during search operations with result details
Search Event Reference
| Event | Timing | Event Detail | Purpose | 
|---|---|---|---|
| searchStart | Before search | { query, timestamp } | Show loading state | 
| searchResult | After search | { query, results, total, duration } | Process search results | 
| searchClear | On clear | { previousQuery, clearedResults } | Reset search state | 
| searchError | On error | { query, error, timestamp } | Handle search errors | 
Search Implementation
Search Integration
🚀 Async Search
Search operations are asynchronous and use FlexSearch for performance. Events provide hooks for loading states.
📊 Search Analytics
Events include timing and result metrics perfect for analytics and performance monitoring.
🎨 Result Highlighting
Use search events to implement custom highlighting and result navigation.
🔧 Custom Search Logic
Implement getSearchValueCallback to customize what data is searchable for each node.
⚡ Performance & Best Practices
Optimize event handling for large trees and complex applications
Best Practices
✅ Do's
- Use event delegation for multiple trees
- Debounce expensive operations in handlers
- Keep event handlers lightweight
- Use proper cleanup in component unmount
- Batch DOM updates after multiple events
❌ Don'ts
- Don't perform heavy computations in handlers
- Don't make synchronous API calls
- Don't manipulate DOM directly
- Don't ignore event timing and order
- Don't forget to handle edge cases
🔧 Memory Management
Optimization Examples
Performance Guide
⚡ Event Performance
- Events are optimized internally with throttling
- Use debouncing for expensive handler operations
- Batch DOM updates to avoid layout thrashing
🧠 Memory Management
- Remove event listeners on component cleanup
- Use weak references for caching
- Clear timeouts and intervals
📊 Large Trees
- Event delegation patterns for multiple trees
- Lazy loading based on expand events
- Virtual scrolling for huge datasets
🔧 Testing Events
Use synthetic events for testing event handlers without user interaction.