fix(edit-content): Reset UI state when navigating between portlets #31410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduced a utility function to initialize the content edit session storage with default values while preserving the sidebar open state. This ensures a clean UI state when switching between different portlets and prevents potential state-related issues.
This pull request introduces several changes aimed at improving the handling of UI state in the
edit-content
module by switching from localStorage to sessionStorage and adding a new utility function. The most important changes include importing and using theinitContentEditSessionStorage
function, modifying how the UI state is managed, and adding tests for the new functionality.Improvements to UI state management:
core-web/apps/dotcms-ui/src/app/view/components/_common/iframe/iframe-porlet-legacy/iframe-porlet-legacy.component.ts
: Added import forinitContentEditSessionStorage
and called it in thengOnInit
method to initialize the UI state. [1] [2]core-web/libs/edit-content/src/index.ts
: Exported theinitContentEditSessionStorage
function.core-web/libs/edit-content/src/lib/store/features/ui.feature.ts
: Modified theactiveSidebarTab
computed property to return 0 if the initial state is 'new'.core-web/libs/edit-content/src/lib/utils/functions.util.ts
: Replaced localStorage with sessionStorage for storing UI state and added theinitContentEditSessionStorage
function to initialize the UI state with default values while preserving theisSidebarOpen
value. [1] [2]Testing enhancements:
core-web/libs/edit-content/src/lib/utils/functions.util.spec.ts
: Added tests for theinitContentEditSessionStorage
function to ensure it initializes the UI state correctly under various conditions. [1] [2]Checklist
Additional Info
** any additional useful context or info **
Screenshots
This PR fixes: #31232