Commit e754349
authored
fix(edit-content): Reset UI state when navigating between portlets (dotCMS#31410)
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 the
`initContentEditSessionStorage` 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`](diffhunk://#diff-5159a82fd083797bc8483174e232b49f0d5a0edc3d2fbda5c37213b3e6e5590cR12):
Added import for `initContentEditSessionStorage` and called it in the
`ngOnInit` method to initialize the UI state.
[[1]](diffhunk://#diff-5159a82fd083797bc8483174e232b49f0d5a0edc3d2fbda5c37213b3e6e5590cR12)
[[2]](diffhunk://#diff-5159a82fd083797bc8483174e232b49f0d5a0edc3d2fbda5c37213b3e6e5590cR67-R69)
*
[`core-web/libs/edit-content/src/index.ts`](diffhunk://#diff-8e4ebf6e3bd0e536ddd7567da45f2092c49a46801b2e8cfa22531cfd312d137fR3):
Exported the `initContentEditSessionStorage` function.
*
[`core-web/libs/edit-content/src/lib/store/features/ui.feature.ts`](diffhunk://#diff-b48dd48cbc0230fe3f75c2f1ef1f26972cc446fc4bbc43a55adc22f74b27f888L59-R64):
Modified the `activeSidebarTab` computed property to return 0 if the
initial state is 'new'.
*
[`core-web/libs/edit-content/src/lib/utils/functions.util.ts`](diffhunk://#diff-99ac6732d97f8e73c67b5464dfb645a4ae4ec51a80005cf22d7f83a27dc43c74L316-R325):
Replaced localStorage with sessionStorage for storing UI state and added
the `initContentEditSessionStorage` function to initialize the UI state
with default values while preserving the `isSidebarOpen` value.
[[1]](diffhunk://#diff-99ac6732d97f8e73c67b5464dfb645a4ae4ec51a80005cf22d7f83a27dc43c74L316-R325)
[[2]](diffhunk://#diff-99ac6732d97f8e73c67b5464dfb645a4ae4ec51a80005cf22d7f83a27dc43c74L336-R356)
Testing enhancements:
*
[`core-web/libs/edit-content/src/lib/utils/functions.util.spec.ts`](diffhunk://#diff-001fcca242290eaaace5b2b311d3fe695f710dc2c0dca7738785c21fef92e1adR28-R29):
Added tests for the `initContentEditSessionStorage` function to ensure
it initializes the UI state correctly under various conditions.
[[1]](diffhunk://#diff-001fcca242290eaaace5b2b311d3fe695f710dc2c0dca7738785c21fef92e1adR28-R29)
[[2]](diffhunk://#diff-001fcca242290eaaace5b2b311d3fe695f710dc2c0dca7738785c21fef92e1adR807-R894)
### Checklist
- [x] Tests
- [ ] Translations
- [ ] Security Implications Contemplated (add notes if applicable)
### Additional Info
** any additional useful context or info **
### Screenshots
Original | Updated
:-------------------------:|:-------------------------:
** original screenshot ** | ** updated screenshot **1 parent 4f65bac commit e754349
File tree
11 files changed
+812
-89
lines changed- .cursor
- rules
- core-web
- apps/dotcms-ui/src/app/view/components/_common/iframe/iframe-porlet-legacy
- libs
- dotcms-models/src
- lib
- edit-content/src
- lib
- components/dot-edit-content-sidebar
- store/features
- utils
11 files changed
+812
-89
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
66 | 73 | | |
67 | 74 | | |
68 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
1 | 16 | | |
2 | 17 | | |
3 | 18 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
12 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
13 | 33 | | |
14 | 34 | | |
15 | 35 | | |
16 | 36 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 37 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 38 | | |
30 | 39 | | |
31 | | - | |
32 | | - | |
33 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
34 | 50 | | |
35 | | - | |
36 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
37 | 61 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | 62 | | |
| 63 | + | |
47 | 64 | | |
| 65 | + | |
| 66 | + | |
48 | 67 | | |
49 | | - | |
50 | | - | |
51 | | - | |
| 68 | + | |
| 69 | + | |
52 | 70 | | |
53 | 71 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 72 | + | |
| 73 | + | |
68 | 74 | | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
Lines changed: 65 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
137 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
138 | 194 | | |
139 | 195 | | |
140 | | - | |
| 196 | + | |
141 | 197 | | |
142 | | - | |
| 198 | + | |
143 | 199 | | |
| 200 | + | |
144 | 201 | | |
145 | | - | |
| 202 | + | |
146 | 203 | | |
147 | | - | |
| 204 | + | |
148 | 205 | | |
149 | 206 | | |
| 207 | + | |
150 | 208 | | |
151 | | - | |
| 209 | + | |
152 | 210 | | |
153 | 211 | | |
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
0 commit comments