Commit d1c56c9
chore(runway): cherry-pick fix: invalid order book buttons cp-7.62.0 (#24889)
- fix: invalid order book buttons cp-7.62.0 (#24878)
## **Description**
This PR fixes the action buttons on the Order Book screen
(`PerpsOrderBookView`) to show **Modify/Close** buttons when the user
has an open position, instead of always showing **Long/Short** buttons.
**Problem:** The Order Book screen always displayed Long/Short buttons,
even when the user had an existing position for that market.
**Solution:** Added position-checking logic (consistent with
`PerpsMarketDetailsView`) to conditionally render:
- **Modify/Close** buttons when user has an existing position
- **Long/Short** buttons when no position exists
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
[TAT-2224](https://consensyssoftware.atlassian.net/browse/TAT-2224)
#24879
## **Manual testing steps**
```gherkin
Feature: Order Book action buttons based on position
Scenario: User views Order Book without an open position
Given user has no open position for BTC
When user navigates to the BTC Order Book screen
Then user sees "Long" and "Short" buttons
Scenario: User views Order Book with an open long position
Given user has an open long position for BTC
When user navigates to the BTC Order Book screen
Then user sees "Modify" and "Close Long" buttons
Scenario: User views Order Book with an open short position
Given user has an open short position for BTC
When user navigates to the BTC Order Book screen
Then user sees "Modify" and "Close Short" buttons
Scenario: User taps Modify button
Given user has an open position for BTC
And user is on the BTC Order Book screen
When user taps the "Modify" button
Then the modify action sheet opens
Scenario: User taps Close button
Given user has an open position for BTC
And user is on the BTC Order Book screen
When user taps the "Close Long" or "Close Short" button
Then user is navigated to the close position flow
```
## **Screenshots/Recordings**
### **Before**
- Order Book always shows Long/Short buttons regardless of position
status
### **After**
- Order Book shows Modify/Close buttons when position exists
- Order Book shows Long/Short buttons when no position exists
https://github.com/user-attachments/assets/c3427894-b62b-42ab-b5a2-d49157c2bc38
## **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-2224]:
https://consensyssoftware.atlassian.net/browse/TAT-2224?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Updates `PerpsOrderBookView` to reflect existing positions and enable
position management actions.
>
> - Conditionally render `Modify` and `Close` buttons (replacing
`Long`/`Short`) when `useHasExistingPosition` returns a position; label
`Close Long`/`Close Short` based on size sign
> - Wire actions: `Modify` opens bottom sheet via
`usePositionManagement`; `Close` navigates with
`navigateToClosePosition`; render `PerpsSelectModifyActionView` when
sheet is visible
> - Preserve `Long`/`Short` buttons when no position exists; maintain
A/B color handling
> - Add new test IDs (`perps-order-book-modify-button`,
`perps-order-book-close-button`) and i18n strings
> - Expand tests to cover conditional rendering, modify sheet open, and
close navigation
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
be0ca08. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[8293e94](8293e94)
[TAT-2224]:
https://consensyssoftware.atlassian.net/browse/TAT-2224?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[TAT-2224]:
https://consensyssoftware.atlassian.net/browse/TAT-2224?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Co-authored-by: abretonc7s <107169956+abretonc7s@users.noreply.github.com>1 parent 5168c3f commit d1c56c9
3 files changed
Lines changed: 309 additions & 40 deletions
File tree
- app/components/UI/Perps
- Views/PerpsOrderBookView
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
| 638 | + | |
| 639 | + | |
638 | 640 | | |
639 | 641 | | |
640 | 642 | | |
| |||
Lines changed: 195 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
124 | | - | |
| 127 | + | |
125 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
126 | 134 | | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| 138 | + | |
130 | 139 | | |
131 | 140 | | |
132 | 141 | | |
| |||
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
142 | 166 | | |
143 | 167 | | |
144 | 168 | | |
| |||
238 | 262 | | |
239 | 263 | | |
240 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
241 | 274 | | |
242 | 275 | | |
243 | 276 | | |
| |||
576 | 609 | | |
577 | 610 | | |
578 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
579 | 773 | | |
580 | 774 | | |
581 | 775 | | |
| |||
0 commit comments