Commit 65a4ede
chore(runway): cherry-pick fix(perps): decouple home sort from market list and remove leverage skeleton blink [TAT-2544 TAT-2454] cp-7.66.0 (#26052)
- fix(perps): decouple home sort from market list and remove leverage
skeleton blink [TAT-2544 TAT-2454] cp-7.66.0 (#25977)
## **Description**
1. Decouple Perps Home sorting from Market List sorting
The Perps Home sections (Crypto, Stocks, Commodities, Forex) were
reading the same sort preference that the Market List search writes to.
This meant that when a user changed the sort in the market search (e.g.,
to "Funding Rate"), the home screen sections would also re-sort — which
isn't the intended behavior. Home sections should always surface the
highest-volume markets regardless of what the user does in search.
The fix removes the dependency on `selectPerpsMarketFilterPreferences`
in `usePerpsHomeData` and hardcodes the home sort to Volume descending.
The Market List continues to use and persist its own sort preference
independently.
2. Remove skeleton loader blink on leverage bottom sheet
When adjusting leverage via the slider or preset buttons, the
liquidation banner and liquidation price would rapidly toggle between a
skeleton placeholder and the actual value. This created a jarring
"blink" effect — especially during slider drags, where every tick
triggered the skeleton. The current price row right below it just
updates its value in place with no loading state, making the
inconsistency more noticeable.
The fix caches the last valid liquidation price and percentage in refs,
so the UI always shows either the latest calculated value or the
previously known one. On first open (before any calculation has
completed), it shows -- as a placeholder instead of a skeleton shimmer.
The banner colors (safe/caution/medium/high) are unaffected because
they're driven by the leverage slider position, not the liquidation
price calculation.
## **Changelog**
CHANGELOG entry: Fixed a flickering skeleton loader on the leverage
bottom sheet when adjusting leverage, and decoupled Perps Home sorting
from the market search sort preference so home sections always sort by
volume.
## **Related issues**
Fixes:
[TAT-2544](https://consensyssoftware.atlassian.net/browse/TAT-2544)
Fixes:
[TAT-2454](https://consensyssoftware.atlassian.net/browse/TAT-2454)
## **Manual testing steps**
```gherkin
Feature: Perps Home sections sort independently from Market List
Scenario: Home sections always sort by volume
Given user is on the Perps Home screen
When user opens the Market List and changes sort to "Funding Rate"
And user navigates back to Perps Home
Then all home sections (Crypto, Stocks, Commodities, Forex) remain sorted by descending volume
Feature: Leverage bottom sheet liquidation display
Scenario: No skeleton blink when dragging leverage slider
Given user opens the leverage bottom sheet on any market
When user drags the leverage slider back and forth
Then the liquidation banner text and price update in place without skeleton flashing
And the banner color transitions smoothly based on leverage risk level
Scenario: No skeleton blink when tapping preset buttons
Given user opens the leverage bottom sheet
When user taps different preset leverage buttons (2x, 5x, 10x, etc.)
Then the liquidation values tick to the new values without a skeleton placeholder appearing
Scenario: Initial open shows placeholder
Given user opens the leverage bottom sheet for the first time
When the liquidation price has not yet been calculated
Then the liquidation price and percentage show "--" until the first value arrives
```
## **Screenshots/Recordings**
https://github.com/user-attachments/assets/f69fdc60-82c9-479f-ba8d-7d7274b1713b
https://github.com/user-attachments/assets/ea03375d-1803-4cc5-8066-2169b8e3b130
## **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.
[TAT-2544]:
https://consensyssoftware.atlassian.net/browse/TAT-2544?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches user-facing trading UX and introduces timing/state logic
around debounced async liquidation-price updates, which could regress
displayed values if edge cases slip through.
>
> **Overview**
> **Perps Home sorting is now fixed to volume defaults.**
`usePerpsHomeData` no longer reads persisted market-list sort
preferences and instead always sorts home sections by `Volume` with the
default direction.
>
> **Leverage bottom sheet liquidation UI is reworked to avoid flicker
and stale data.** The skeleton implementation is replaced with
cached/placeholder display plus a recalculation state that only shows
shimmer placeholders after user-initiated leverage changes (with a
minimum display time to avoid stale async completions), while passive
price updates keep showing the last valid value. Styling is tweaked with
a fixed `minHeight` on the warning container to prevent layout shifts,
and tests are updated/expanded to cover the new placeholder/skeleton
behavior and stale-cache prevention.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
1e53413. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[f95e2bb](f95e2bb)
[TAT-2544]:
https://consensyssoftware.atlassian.net/browse/TAT-2544?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Co-authored-by: Nick Gambino <35090461+gambinish@users.noreply.github.com>1 parent eb0441a commit 65a4ede
4 files changed
Lines changed: 262 additions & 85 deletions
File tree
- app/components/UI/Perps
- components/PerpsLeverageBottomSheet
- hooks
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
Lines changed: 96 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
35 | 56 | | |
36 | 57 | | |
37 | 58 | | |
| |||
620 | 641 | | |
621 | 642 | | |
622 | 643 | | |
623 | | - | |
| 644 | + | |
624 | 645 | | |
625 | 646 | | |
626 | 647 | | |
627 | 648 | | |
628 | 649 | | |
629 | 650 | | |
630 | 651 | | |
631 | | - | |
| 652 | + | |
632 | 653 | | |
633 | 654 | | |
634 | 655 | | |
| |||
1156 | 1177 | | |
1157 | 1178 | | |
1158 | 1179 | | |
1159 | | - | |
1160 | | - | |
| 1180 | + | |
| 1181 | + | |
1161 | 1182 | | |
1162 | 1183 | | |
1163 | 1184 | | |
1164 | 1185 | | |
1165 | 1186 | | |
1166 | 1187 | | |
1167 | | - | |
1168 | | - | |
| 1188 | + | |
| 1189 | + | |
1169 | 1190 | | |
1170 | 1191 | | |
1171 | 1192 | | |
1172 | 1193 | | |
1173 | 1194 | | |
1174 | 1195 | | |
1175 | 1196 | | |
1176 | | - | |
1177 | | - | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
1178 | 1202 | | |
1179 | 1203 | | |
1180 | | - | |
| 1204 | + | |
1181 | 1205 | | |
1182 | 1206 | | |
1183 | 1207 | | |
1184 | 1208 | | |
1185 | 1209 | | |
1186 | 1210 | | |
1187 | | - | |
1188 | | - | |
| 1211 | + | |
| 1212 | + | |
1189 | 1213 | | |
1190 | 1214 | | |
1191 | 1215 | | |
1192 | 1216 | | |
1193 | 1217 | | |
1194 | 1218 | | |
1195 | 1219 | | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
| 1220 | + | |
| 1221 | + | |
1200 | 1222 | | |
1201 | 1223 | | |
1202 | | - | |
| 1224 | + | |
1203 | 1225 | | |
1204 | 1226 | | |
1205 | 1227 | | |
| |||
1215 | 1237 | | |
1216 | 1238 | | |
1217 | 1239 | | |
1218 | | - | |
| 1240 | + | |
1219 | 1241 | | |
1220 | 1242 | | |
1221 | 1243 | | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
1222 | 1247 | | |
1223 | 1248 | | |
1224 | | - | |
1225 | | - | |
| 1249 | + | |
| 1250 | + | |
1226 | 1251 | | |
1227 | 1252 | | |
1228 | 1253 | | |
1229 | 1254 | | |
1230 | 1255 | | |
1231 | | - | |
| 1256 | + | |
1232 | 1257 | | |
1233 | 1258 | | |
1234 | 1259 | | |
| |||
1237 | 1262 | | |
1238 | 1263 | | |
1239 | 1264 | | |
1240 | | - | |
1241 | | - | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
1242 | 1316 | | |
1243 | 1317 | | |
1244 | 1318 | | |
| |||
0 commit comments