Externalize selected value in redux to avoid selected state switch#1384
Conversation
There was a problem hiding this comment.
Pull request overview
This PR externalizes the currently selected sidebar panel into Redux so the user’s sidebar selection is preserved when switching between desktop and mobile layouts (e.g., across responsive breakpoints).
Changes:
- Add
selectedSidebarOptionandsetSidebarOptiontoEditorSlice. - Update
Sidebarto initialize/persist the selected panel via Redux instead of purely local state. - Add a regression test to ensure the selected sidebar panel remains active after resizing across the mobile breakpoint.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/redux/EditorSlice.js | Adds Redux state + action to persist selected sidebar option. |
| src/components/Menus/Sidebar/Sidebar.jsx | Reads/writes selected option from Redux and adjusts default/validation logic. |
| src/components/WebComponentProject/WebComponentProject.test.js | Adds breakpoint-resize regression test; introduces a “real store” render helper. |
| src/components/Mobile/MobileProject/MobileProject.test.js | Removes some sidebar rendering tests (likely superseded by the new integration-style resize test). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1aee796 to
51a282b
Compare
51a282b to
de09de5
Compare
There was a problem hiding this comment.
Pull request overview
Moves the “selected sidebar tab” state from local component state into the global Redux store so the selection persists when the UI switches between desktop (Project) and mobile (MobileProject) layouts.
Changes:
- Add
selectedSidebarOptiontoeditorRedux state and introducesetSidebarOptionaction. - Update
Sidebarto initialize from Redux selection (with default fallback) and persist updates back to Redux. - Add a WebComponentProject test that verifies the selected sidebar panel survives resizing across the mobile breakpoint (and that
nullpersists a collapsed sidebar).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/redux/EditorSlice.js |
Adds persisted selectedSidebarOption state and setSidebarOption action to editor Redux slice. |
src/components/Menus/Sidebar/Sidebar.jsx |
Reads/writes selected sidebar option to Redux and validates availability against current sidebar options. |
src/components/WebComponentProject/WebComponentProject.test.js |
Adds real-store test coverage for persisting sidebar selection across desktop/mobile layout switches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
de09de5 to
2a4c02c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Store the selected sidebar option in Redux so desktop and mobile share the same panel state. Preserve collapsed state and keep the default panel in sync when instructions appear after mount.
2a4c02c to
a316165
Compare
Closes: https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1146
This we way avoid that when it changes between mobile and desktop it looses previous state.
The PR moves the "memory" of which sidebar tab is selected into the global Redux store.
optionIsAvailableto ensure that if the sidebar tries to open a tab that doesn't exist in the current context, it reverts to a default.Screen.Recording.2026-03-16.at.13.00.25.mov
Adds also test to cover this.