Commit f1d6778
committed
Resolves #4277 ([FR-1470](https://lablup.atlassian.net/browse/FR-1470))
## Summary
This PR fixes the issue where board items on Dashboard and Start pages revert to their original positions after drag & drop operations. Users can now properly rearrange board items and the layout will be preserved across page refreshes.
## Changes
### DashboardPage.tsx
- Added useMemo optimization for mergedBoardItems calculation
- Implemented localStorage order preservation using Map-based sorting
- Import fix: Added useMemo to React imports
### StartPage.tsx
- Refactored board items logic to match DashboardPage pattern
- Replaced state-based approach with useMemo and direct localStorage integration
- Removed unnecessary boardItems state and setBoardItems calls
- Improved performance by eliminating redundant re-renders
## Technical Implementation
The key fix involves sorting merged items by localStorage order while preserving new items:
1. Map initialBoardItems with localStorage data
2. Create order map from localStorage indices
3. Sort merged items using localStorage order
4. New items get MAX_VALUE (placed at end)
## Impact
- Fixed: Board items now maintain their position after drag & drop
- Performance: Optimized with useMemo to prevent unnecessary recalculations
- Backward compatibility: New items automatically appear at the end
- Consistency: Both Dashboard and Start pages use the same pattern
## Test Case
1. Go to Dashboard or Start page
2. Drag and drop any board item to a new position
3. Refresh the page
4. Expected: Item remains in the new position
5. Before this fix: Item would revert to original position
[FR-1470]: https://lablup.atlassian.net/browse/FR-1470?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 53784f3 commit f1d6778
2 files changed
+38
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
181 | | - | |
182 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
186 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
187 | 195 | | |
188 | 196 | | |
| 197 | + | |
189 | 198 | | |
190 | 199 | | |
191 | 200 | | |
192 | 201 | | |
193 | 202 | | |
194 | 203 | | |
195 | | - | |
| 204 | + | |
196 | 205 | | |
197 | 206 | | |
198 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| |||
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
171 | | - | |
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
| |||
0 commit comments