fix(properties): enhance element detection in properties panel with recursive search and retry mechanism

This commit is contained in:
Juergen Kunz
2025-06-16 13:10:12 +00:00
parent fca47b87fb
commit 6bdb8c78b7
7 changed files with 107 additions and 11 deletions

30
readme.plan.md Normal file
View File

@ -0,0 +1,30 @@
# Fix Properties Panel Element Detection
To fix the element detection issue, reread CLAUDE.md first.
## Problem Analysis
The properties panel has timing issues detecting rendered elements because:
1. Elements are rendered asynchronously via lit's `render()` in the dashboard
2. Properties panel tries to find elements immediately without waiting for render completion
3. Element search only looks at direct children, missing nested/shadow DOM elements
## Implementation Plan
### 1. Add proper synchronization
- Add a delay or await render completion before element detection
- Use MutationObserver or lit's updateComplete promises
### 2. Improve element search algorithm
- Search recursively through all descendants, not just direct children
- Handle shadow DOM boundaries properly
- Support elements wrapped in containers
### 3. Add retry mechanism
- If element not found, retry after a delay
- Add maximum retry attempts to prevent infinite loops
- Clear error state when element is eventually found
## Code Changes Required
1. Modify `wcc-properties.ts` createProperties() method
2. Add element search utility function
3. Improve error handling and user feedback