-
Notifications
You must be signed in to change notification settings - Fork 67
fix (design library): re-render preview of selected pattern when changing categories #3627
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
base: develop
Are you sure you want to change the base?
fix (design library): re-render preview of selected pattern when changing categories #3627
Conversation
WalkthroughIntroduces prevSelectedNumRef and new useEffect blocks to gate preview rendering based on selectedNum, shadowRoot, content, and color scheme changes. Adds early returns to prevent duplicate renders, coordinates renderPreview calls, and schedules scale adjustments via requestAnimationFrame. Maintains prevSelectedTabRef behavior while integrating new guard logic into the render/scale flow. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor C as Component
participant H as usePreviewRenderer (hook)
participant E1 as useEffect: selection/shadowRoot
participant E2 as useEffect: render & scale
participant DOM as shadowRoot
participant R as renderPreview
participant RAF as requestAnimationFrame
C->>H: Invoke with props (selectedNum, content, colorScheme, shadowRoot)
H->>E1: Monitor selectedNum, shadowRoot
Note over E1: Guard transitions, update prevSelectedNumRef
E1-->>R: Conditionally call renderPreview when content exists
H->>E2: Monitor content, colorScheme, selection state
Note over E2: Skip on guarded states
E2->>R: Render preview when required
R-->>DOM: Update preview DOM
E2->>RAF: Schedule scale adjustment
RAF-->>DOM: Apply scale changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings
📚 Learning: 2025-09-25T08:17:15.564Z
Applied to files:
🧬 Code graph analysis (1)src/components/design-library-list/use-preview-renderer.js (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Pull request artifacts
|
Summary by CodeRabbit
Bug Fixes
Refactor