fix: card templates panel not re-opening#8895
Conversation
…and related components
WalkthroughMoves Card Templates visibility from local component state into editor-global Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant CardWrapper as CardWrapper (mobile)
participant Editor as EditorProvider
participant Drawer as Drawer / ActiveSlide
User->>CardWrapper: Click "Select Card Template"
CardWrapper->>Editor: dispatch SetShowCardTemplates(true)
CardWrapper->>Editor: dispatch SetSelectedBlock(...)
CardWrapper->>Editor: dispatch SetActiveSlide(Drawer)
Editor-->>Drawer: state.showCardTemplates = true
Drawer-->>User: Render Card Templates panel
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
View your CI Pipeline Execution ↗ for commit 6d55404
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit 8dc17d6 ☁️ Nx Cloud last updated this comment at |
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
This comment has been minimized.
This comment has been minimized.
…anel-fails-to-reopen-for-new-cards
…anel-fails-to-reopen-for-new-cards
…1320) Prevent card templates panel from reopening when card properties are changed on an empty card. The reducer now only resets showCardTemplates to true when navigating to a different step, not when mutation handlers re-select the current step via SetEditorFocusAction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…anel-fails-to-reopen-for-new-cards
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
libs/journeys/ui/src/libs/EditorProvider/EditorProvider.tsx (1)
257-289:⚠️ Potential issue | 🟠 MajorReset
showCardTemplatesanywhere the selected step can change.These new branches only recalculate the flag for direct step-selection actions.
SetStepsActioncan also replaceselectedStep/selectedStepId(fallback after a step delete, step-list refresh, initial hydration, etc.) and currently carries the oldshowCardTemplatesvalue forward; becauseProperties.tsxtreatsshowCardTemplates === falseas “panel closed”, that stalefalsecan recreate the same UX bug on the next step. Also, Line 258 keys “same step” offstate.selectedStepIdonly, soEditorProviderwill flipinitialState.showCardTemplates: falseback totrueon mount whenselectedStepis present but the id has not been hydrated yet. Please centralize the current-step comparison (state.selectedStepId ?? state.selectedStep?.id) and reuse it inSetSelectedStepAction,SetSelectedStepByIdAction, andSetStepsAction.Suggested direction
case 'SetSelectedStepAction': { - const isSameStep = action.selectedStep?.id === state.selectedStepId + const currentStepId = state.selectedStepId ?? state.selectedStep?.id + const isSameStep = action.selectedStep?.id === currentStepId return { ...state, selectedStepId: action.selectedStep?.id, selectedStep: action.selectedStep, selectedBlockId: action.selectedStep?.id, selectedBlock: action.selectedStep, activeCanvasDetailsDrawer: ActiveCanvasDetailsDrawer.Properties, activeContent: ActiveContent.Canvas, showCardTemplates: isSameStep ? state.showCardTemplates : true } }// Reuse the same currentStepId comparison in SetSelectedStepByIdAction, // and recompute showCardTemplates in SetStepsAction whenever selectedStep?.id changes.Also applies to: 398-423
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@libs/journeys/ui/src/libs/EditorProvider/EditorProvider.tsx` around lines 257 - 289, Centralize the current-step comparison by computing a single currentStepId = state.selectedStepId ?? state.selectedStep?.id at the top of the reducer and use it in SetSelectedStepAction, SetSelectedStepByIdAction and SetStepsAction to determine isSameStep; then recompute showCardTemplates based on whether the new selected step id equals currentStepId (preserve state.showCardTemplates only when it's the same step), and in SetStepsAction ensure you recalc showCardTemplates when the selectedStep/selectedStepId might be replaced (e.g., after delete/hydration) so stale false values aren't carried forward; update references to selectedStepId/selectedStep in those cases (SetSelectedStepAction, SetSelectedStepByIdAction, SetStepsAction) to use the new comparison.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@libs/journeys/ui/src/libs/EditorProvider/EditorProvider.tsx`:
- Around line 257-289: Centralize the current-step comparison by computing a
single currentStepId = state.selectedStepId ?? state.selectedStep?.id at the top
of the reducer and use it in SetSelectedStepAction, SetSelectedStepByIdAction
and SetStepsAction to determine isSameStep; then recompute showCardTemplates
based on whether the new selected step id equals currentStepId (preserve
state.showCardTemplates only when it's the same step), and in SetStepsAction
ensure you recalc showCardTemplates when the selectedStep/selectedStepId might
be replaced (e.g., after delete/hydration) so stale false values aren't carried
forward; update references to selectedStepId/selectedStep in those cases
(SetSelectedStepAction, SetSelectedStepByIdAction, SetStepsAction) to use the
new comparison.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 42b30b0d-5422-49de-9c39-9f7ae36444ab
📒 Files selected for processing (2)
libs/journeys/ui/src/libs/EditorProvider/EditorProvider.spec.tsxlibs/journeys/ui/src/libs/EditorProvider/EditorProvider.tsx
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Urim Chae <urim027@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary by CodeRabbit
Bug Fixes
Tests
Documentation