Skip to content

Externalize selected value in redux to avoid selected state switch#1384

Open
abcampo-iry wants to merge 2 commits intomainfrom
issues/1146-state-is-not-shared-between-mobile-desktop
Open

Externalize selected value in redux to avoid selected state switch#1384
abcampo-iry wants to merge 2 commits intomainfrom
issues/1146-state-is-not-shared-between-mobile-desktop

Conversation

@abcampo-iry
Copy link
Contributor

@abcampo-iry abcampo-iry commented Mar 16, 2026

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.

  • The sidebar It checks selectedSidebarOption first. If it's undefined, it falls back to a "default" option (like "instructions" or "file").
  • When a user clicks a tab, the updateOption function now calls dispatch -> setSidebarOption
  • It adds a (safety / paranoid check) optionIsAvailable to 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.

- This we way avoid that when it changes between mobile and desktop it
  looses previous state
Copilot AI review requested due to automatic review settings March 16, 2026 09:19
@abcampo-iry abcampo-iry temporarily deployed to previews/1384/merge March 16, 2026 09:19 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry marked this pull request as draft March 16, 2026 09:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 selectedSidebarOption and setSidebarOption to EditorSlice.
  • Update Sidebar to 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.

@abcampo-iry abcampo-iry temporarily deployed to previews/1384/merge March 16, 2026 09:48 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1146-state-is-not-shared-between-mobile-desktop branch from 1aee796 to 51a282b Compare March 16, 2026 10:06
@abcampo-iry abcampo-iry marked this pull request as ready for review March 16, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants