CP-14877: switch between Long and Short on the Place Order screen via native select - #4006
Open
bogdandobritoiu wants to merge 8 commits into
Open
CP-14877: switch between Long and Short on the Place Order screen via native select#4006bogdandobritoiu wants to merge 8 commits into
bogdandobritoiu wants to merge 8 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…geSide is set Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…olish Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
bogdandobritoiu
requested review from
B0Y3R-AVA,
atn4z7,
onghwan and
ruijia1in
as code owners
July 22, 2026 15:31
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the perps Place Order flow by allowing users to switch Long/Short directly on the screen via the existing native DropdownMenu select, and by improving the UI feedback when the selected side’s max capacity is lower than the currently dialed amount.
Changes:
- Converted
PlaceOrderContext.sideinto internal state seeded from a renamedinitialSideprop, and added aswitchSideaction that clears TP/SL toggles and prices when the side changes. - Updated
PositionPillto optionally render the Long/Short label as a native dropdown trigger (whenonChangeSideis provided), leaving other screens’ behavior unchanged. - Updated
PerpetualsPlaceOrderScreento wire side switching and to show a danger-styled “Reduce your position…” caption when the amount exceeds the current side’s capacity; added/updated unit tests accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core-mobile/app/new/features/trade/perpetuals/screens/PerpetualsPlaceOrderScreen.tsx | Wires switchSide into the UI and adds a capacity-aware caption under the amount dial. |
| packages/core-mobile/app/new/features/trade/perpetuals/screens/PerpetualsPlaceOrderScreen.test.tsx | Extends screen tests to cover capacity warning caption and pill side-switch wiring/label derivations. |
| packages/core-mobile/app/new/features/trade/perpetuals/hooks/useSeededPlaceOrderProps.ts | Renames seeded side to initialSide to reflect provider seeding semantics. |
| packages/core-mobile/app/new/features/trade/perpetuals/hooks/useSeededPlaceOrderProps.test.ts | Updates resolver tests to assert initialSide. |
| packages/core-mobile/app/new/features/trade/perpetuals/contexts/PlaceOrderContext.tsx | Introduces stateful side plus switchSide action that clears TP/SL on side change. |
| packages/core-mobile/app/new/features/trade/perpetuals/contexts/PlaceOrderContext.test.tsx | Adds focused unit tests for switchSide behavior (clearing TP/SL, no-op, liquidation recompute). |
| packages/core-mobile/app/new/features/trade/perpetuals/components/PositionPill.tsx | Adds optional dropdown side selector behavior via DropdownMenu when onChangeSide is provided. |
| packages/core-mobile/app/new/features/trade/perpetuals/components/PositionPill.test.tsx | Adds component tests for dropdown rendering, selection state, and event handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage report ✅2/2 packages passed thresholds 🟢 @avalabs/core-mobile
🟢 @avalabs/k2-alpine
Artifacts and threshold sources
Source run: Mobile PR |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Bogdan Dobritoiu <bogdan.dobri@gmail.com>
ruijia1in
previously approved these changes
Jul 22, 2026
# Conflicts: # packages/core-mobile/app/new/features/trade/perpetuals/contexts/PlaceOrderContext.test.tsx # packages/core-mobile/app/new/features/trade/perpetuals/screens/PerpetualsPlaceOrderScreen.test.tsx
ruijia1in
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ticket: CP-14877
Lets the user switch between Long and Short directly on the perps Place Order screen using our native select (zeego
DropdownMenu), instead of backing out of the modal and re-entering from the market details screen.PlaceOrderContext:sideis now state (seeded from the renamedinitialSideprop) with an atomicswitchSideaction. Flipping direction clears take-profit/stop-loss prices and toggles, since trigger prices are direction-specific — a long's TP sits on the wrong side of the price for a short. Switching to the current side is a no-op.PositionPill: new optionalonChangeSideprop. When set (Place Order screen only), the Long/Short label becomes a native dropdown trigger with a chevron affordance and the current side check-marked. Trigger/Close/Manage screens pass nothing and render exactly as before.PerpetualsPlaceOrderScreen: wiresswitchSideinto the pill. Subtitle, slide-button label, liquidation price, and buy-vs-sell position capacity all recompute from existingsidederivations. When the flipped side's capacity is below the dialed amount, the caption under the dial now shows a danger-colored "Reduce your position to $X or less" warning (submit was already correctly disabled by the existing capacity guard; this makes the reason visible).No new dependencies. No breaking changes.
Screenshots/Videos
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-07-22.at.17.42.11.mov
Testing
iOS - 9393
Android - 9394
Dev Testing
Happy path:
Edge cases:
Bitrise build:
iOS - 9384
Android - 9385
QA Testing
Checklist
Please check all that apply (if applicable)
🤖 Generated with Claude Code