Commit 74f7006
Fix Nav Drawer interaction and persistence in Static SSR (#64)
* Fix MudStaticNavDrawerToggle and MudDrawer interaction in Static SSR
- Implemented state persistence for drawers using localStorage to preserve open/closed state across navigations.
- Added support for Mini drawer variant in the JavaScript logic.
- Improved resize monitoring to correctly handle both Responsive and Mini drawers.
- Updated breakpoint values to match MudBlazor defaults.
- Refactored layout class replacement to be more robust.
- Fixed an issue where the drawer state would reset on every navigation during enhanced loading.
Co-authored-by: Anu6is <[email protected]>
* fix(drawer): implement state persistence and sync for MudStaticNavDrawerToggle
- Implemented localStorage persistence in JS for drawer state.
- Refactored JS to correctly handle MudBlazor responsive/mini layout classes.
- Added Open/OpenChanged parameters to MudStaticNavDrawerToggle for state binding.
- Added OnAfterRenderAsync sync logic in MudStaticNavDrawerToggle to restore state during WASM transition.
- Updated demo project to utilize @bind-Open on the toggle component.
- Removed debug logs and cleaned up verification artifacts.
Co-authored-by: Anu6is <[email protected]>
* fix(drawer): implement state persistence and sync for all drawer variants
- Implemented localStorage persistence in JS for drawer state.
- Refactored JS layout class parsing to correctly handle Responsive, Mini, and Persistent variants with or without breakpoints.
- Added Open/OpenChanged parameters to MudStaticNavDrawerToggle for state binding.
- Implemented state sync in MudStaticNavDrawerToggle.OnAfterRenderAsync to restore state during transitions to interactive mode.
- Updated demo project to support @bind-Open on the toggle component.
- Improved JS resilience by handling varying layout class section counts.
Co-authored-by: Anu6is <[email protected]>
* fix(drawer): improve SSR persistence and WASM transition sync
- Added Cookie-based state persistence in JS to support server-side state awareness.
- Implemented synchronous state sync in WASM OnInitialized using IJSInProcessRuntime to eliminate flicker.
- Implemented HttpContext cookie sync in SSR OnInitialized for correct initial rendering.
- Enhanced JS layout class parsing for Persistent, Mini, and Responsive variants.
- Ensured stable storage keys ('default') when no DrawerId is provided.
- Updated demo project to use @bind-Open on the toggle component.
Co-authored-by: Anu6is <[email protected]>
* fix(drawer): improve mobile support and state persistence for MudStaticNavDrawerToggle
- Implemented state persistence via Cookies and localStorage to support Static SSR and hydration.
- Added PersistentComponentState to bridge state from SSR to WASM, preventing flickering.
- Refactored JS layout logic to be anchor-aware, supporting multiple drawers.
- Added comprehensive unit tests for drawer state persistence and multi-drawer scenarios.
- Improved resize monitoring for responsive and mini variants on mobile.
Co-authored-by: Anu6is <[email protected]>
* fix(drawer): finalize MudStaticNavDrawerToggle improvements and address feedback
- Refactored MudStaticNavDrawerToggle to avoid direct [Parameter] mutation.
- Added PersistMode parameter to support InteractiveServer and other render modes.
- Updated cookie expiration to session-only for better privacy and consistency.
- Refined multi-drawer layout logic in JS to be anchor-aware.
- Verified all scenarios with comprehensive unit and Playwright tests.
Co-authored-by: Anu6is <[email protected]>
* fix(drawer): finalize MudStaticNavDrawerToggle improvements and address all feedback
- Refactored MudStaticNavDrawerToggle to avoid direct [Parameter] mutation.
- Added PersistMode parameter to support InteractiveServer and other render modes.
- Updated cookie expiration to session-only for better privacy and consistency.
- Refined multi-drawer layout logic in JS to be anchor-aware.
- Implemented `syncDrawerState` to capture automatic state changes in interactive modes (resizing, mini-variant) for persistence in static pages.
- Verified all scenarios with comprehensive unit and Playwright tests.
Co-authored-by: Anu6is <[email protected]>
* nits
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Anu6is <[email protected]>1 parent c6d5181 commit 74f7006
9 files changed
Lines changed: 545 additions & 54 deletions
File tree
- demo/StaticSample/StaticSample.Client/Layout
- src
- wwwroot
- tests/StaticInput.UnitTests
- Components
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
23 | 38 | | |
24 | 39 | | |
25 | 40 | | |
| |||
32 | 47 | | |
33 | 48 | | |
34 | 49 | | |
35 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
36 | 56 | | |
37 | 57 | | |
38 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
26 | 57 | | |
27 | 58 | | |
28 | 59 | | |
| |||
38 | 69 | | |
39 | 70 | | |
40 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 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 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
41 | 207 | | |
0 commit comments