Skip to content

Commit

Permalink
feat(edit-content) discart tab index persistence if the state of the …
Browse files Browse the repository at this point in the history
…content is new
  • Loading branch information
oidacra committed Feb 3, 2025
1 parent df7adbe commit 5958755
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions core-web/libs/edit-content/src/lib/store/features/ui.feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {

import { computed } from '@angular/core';

import { ContentState } from './content.feature';

import { getStoredUIState, saveStoreUIState } from '../../utils/functions.util';
import { EditContentRootState } from '../edit-content.store';

Expand All @@ -29,13 +31,19 @@ export const uiInitialState: UIState = getStoredUIState();
*/
export function withUI() {
return signalStoreFeature(
{ state: type<EditContentRootState>() },
{ state: type<EditContentRootState & ContentState>() },
withState({ uiState: uiInitialState }),
withComputed((store) => ({
/**
* Computed property that returns the currently active tab index
* Computed property that returns the currently active tab index.
* Returns 0 if the initial content state is 'new'.
*/
activeTab: computed(() => store.uiState().activeTab),
activeTab: computed(() => {
const initialState = store.initialContentletState();
const uiState = store.uiState();

return initialState === 'new' ? 0 : uiState.activeTab;
}),
/**
* Computed property that returns the sidebar visibility state
*/
Expand Down

0 comments on commit 5958755

Please sign in to comment.