Commit 348c47e
authored
fix(homepage): revert perps position row to PerpsCard component (#27206)
## **Description**
Replace `PerpsPositionCard` (compact position variant with TP/SL and
ROE) with the simpler `PerpsCard` component for rendering position rows
in the homepage Perps section, matching the pre-homepage-sections tab UI
behavior.
Changes:
- Replace `PositionCardItem` (memoized `PerpsPositionCard` wrapper) with
`PerpsCard` for position rows
- Remove `positionDisplayKey` helper function (only needed for the
custom memo comparator)
- Remove TP/SL loading state logic (`anyPositionHasTpSl`, `tpSlSettled`,
`tpSlReady`) which was only relevant for `PerpsPositionCard`'s compact
position variant
- Update `PerpsCard` mock in tests to handle both `position` and `order`
props
- Remove `positionDisplayKey` unit tests and TP/SL-specific tests
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Refs:
[TMCU-523](https://consensyssoftware.atlassian.net/browse/TMCU-523)
## **Manual testing steps**
```gherkin
Feature: Perps position row on homepage
Scenario: user views open perps positions on the homepage
Given the user has open perps positions
And the homepage Perps section is visible
When user views the position rows
Then the rows display the old/simple PerpsCard format (icon, symbol/leverage + size, value + PnL)
And the rows do not show TP/SL info or ROE
Scenario: user taps a position row
Given the user has open perps positions on the homepage
When user taps a position row
Then the app navigates to the market details for that position
```
## **Screenshots/Recordings**
### **Before**
<img width="300" alt="perps_row_before"
src="https://github.com/user-attachments/assets/3538094a-8d96-4f57-ad8e-58f424b2ed7e"
/>
### **After**
<img width="300" alt="perps_row_after"
src="https://github.com/user-attachments/assets/e4aa46d7-a6be-45e6-80ac-6204ff247246"
/>
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk UI refactor in the homepage Perps section that changes which
component renders position rows and removes TP/SL-related loading
behavior; main risk is minor display/regression or performance
differences during live updates.
>
> **Overview**
> **Homepage Perps position rows are reverted to the simpler `PerpsCard`
UI.** The section no longer uses the memoized `PerpsPositionCard`
wrapper (and its `positionDisplayKey` comparator), so position rows stop
showing TP/SL/ROE-specific behavior and related loading states.
>
> Tests were updated to match the new rendering: the `PerpsCard` mock
now supports both `position` and `order` rows with `onPress`, and
TP/SL/key-stability assertions were removed/rewritten to validate the
simpler position-row output and leverage display.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
811fabe. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 6fe5eee commit 348c47e
2 files changed
Lines changed: 37 additions & 245 deletions
Lines changed: 34 additions & 176 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | | - | |
92 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
93 | 97 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
98 | 110 | | |
99 | 111 | | |
100 | 112 | | |
| |||
217 | 229 | | |
218 | 230 | | |
219 | 231 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | 232 | | |
288 | 233 | | |
289 | 234 | | |
| |||
312 | 257 | | |
313 | 258 | | |
314 | 259 | | |
315 | | - | |
| 260 | + | |
316 | 261 | | |
317 | 262 | | |
318 | 263 | | |
| |||
321 | 266 | | |
322 | 267 | | |
323 | 268 | | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | 269 | | |
348 | 270 | | |
349 | 271 | | |
| |||
353 | 275 | | |
354 | 276 | | |
355 | 277 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
| 278 | + | |
| 279 | + | |
422 | 280 | | |
423 | 281 | | |
424 | | - | |
| 282 | + | |
425 | 283 | | |
426 | 284 | | |
427 | 285 | | |
| |||
434 | 292 | | |
435 | 293 | | |
436 | 294 | | |
437 | | - | |
438 | | - | |
| 295 | + | |
| 296 | + | |
439 | 297 | | |
440 | 298 | | |
441 | 299 | | |
| |||
555 | 413 | | |
556 | 414 | | |
557 | 415 | | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
564 | 422 | | |
565 | 423 | | |
566 | 424 | | |
| |||
584 | 442 | | |
585 | 443 | | |
586 | 444 | | |
587 | | - | |
588 | | - | |
| 445 | + | |
| 446 | + | |
589 | 447 | | |
590 | 448 | | |
591 | 449 | | |
| |||
Lines changed: 3 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | 53 | | |
90 | 54 | | |
91 | 55 | | |
| |||
129 | 93 | | |
130 | 94 | | |
131 | 95 | | |
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 | 96 | | |
163 | 97 | | |
164 | 98 | | |
| |||
333 | 267 | | |
334 | 268 | | |
335 | 269 | | |
336 | | - | |
| 270 | + | |
337 | 271 | | |
338 | 272 | | |
339 | | - | |
340 | | - | |
| 273 | + | |
| 274 | + | |
341 | 275 | | |
342 | 276 | | |
343 | 277 | | |
| |||
0 commit comments