Skip to content
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

Preserve Customize Selections in State on SiteGen Editor Page #464

Merged
merged 7 commits into from
Feb 20, 2024

Conversation

mr-vara
Copy link
Contributor

@mr-vara mr-vara commented Feb 13, 2024

This pull request addresses an enhancement in the SiteGen Editor page, ensuring that user selections are now preserved in the application's state. With this update, when users revisit the page, their previous selections will be retained, providing a more seamless and user-friendly experience.

@mr-vara mr-vara requested a review from arunshenoy99 February 13, 2024 11:19
@mr-vara mr-vara added the Code Review The PR is in Code Review label Feb 13, 2024
Copy link
Member

@arunshenoy99 arunshenoy99 left a comment

Choose a reason for hiding this comment

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

Hi Vara, please review the following recordings/images and confirm if this behaviour is expected:

Colors are not resetting in the preview when clicking reset.

Screen.Recording.2024-02-14.at.9.18.02.AM.mov

Selecting "Pick Your Own Colors" automatically applies the previously selected custom color instead of opening the color palette.

Screen.Recording.2024-02-14.at.9.20.07.AM.mov

Fonts selected in the editor step are not reflected in the preview step, unlike colors.

image

image

Finally, can we please take a look at reducing the number of if else statements in both src/OnboardingSPA/components/Sidebar/components/Customize/DesignColorsPanel/index.js and src/OnboardingSPA/components/Sidebar/components/Customize/DesignFontsPanel/index.js? It seems like there is a lot of nesting, and both of these files have become very hard to understand.

Comment on lines 58 to 62
currentData.sitegen.homepages.active.color.selectedPalette =
null;
currentData.sitegen.homepages.data[
slug
].color.selectedPalette = null;
Copy link
Member

Choose a reason for hiding this comment

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

We should change this to an empty object or array instead of null. Also, if we're already setting all of this to empty at the end of the function, why do all the operations above this? That code can be deleted.

@@ -55,6 +55,12 @@ const DesignColorsPanel = forwardRef(
setSelectedPalette( null );
setCurrentOnboardingData( updatedData );
}
currentData.sitegen.homepages.active.color.selectedPalette =
Copy link
Member

Choose a reason for hiding this comment

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

Can we invert all the if statements in the resetToDefaultColors and other functions to check for negation? This will help reduce the overall nesting in the function.

Comment on lines 131 to 141
if ( ! selectedPalette ) {
const storedSelectedPalette =
currentData.sitegen.homepages.active.color.selectedPalette;
if ( storedSelectedPalette ) {
setSelectedPalette( storedSelectedPalette );
if ( storedSelectedPalette === 'custom' ) {
setShowCustomColors( true );
setSelectedCustomColors( true );
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have so many states like storedCustomColors and storedSelectedPalette custom? Can we use a single state with a common data structure for storing default/pre-defined/custom colors and then just mark that as default/pre-defined/custom in another state variable? This way, we will only have to maintain two states.

@mr-vara mr-vara requested a review from arunshenoy99 February 14, 2024 13:08
@mr-vara mr-vara added QA This PR is in QA and removed Code Review The PR is in Code Review labels Feb 19, 2024
@avneet-raj avneet-raj added Ready to merge The Code Review and QA is done and it can be merged. and removed QA This PR is in QA labels Feb 20, 2024
@mr-vara mr-vara merged commit a9d7b8f into trunk Feb 20, 2024
1 of 5 checks passed
@arunshenoy99 arunshenoy99 deleted the fix-save-selection-customize-sidebar branch September 11, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge The Code Review and QA is done and it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants