Skip to content

fix(perps): apply safe area top inset directly to TPSL header cp-7.78.0#30503

Merged
michalconsensys merged 1 commit into
mainfrom
fix/tpsl-header-safe-area
May 21, 2026
Merged

fix(perps): apply safe area top inset directly to TPSL header cp-7.78.0#30503
michalconsensys merged 1 commit into
mainfrom
fix/tpsl-header-safe-area

Conversation

@michalconsensys

@michalconsensys michalconsensys commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

The TPSL (Take Profit / Stop Loss) page header was intermittently positioned too high, overlapping the status bar / notch area. This occurred both when creating a TPSL from the order screen and when editing a TPSL for an open position.

Root cause: The screen relied on the shimmed SafeAreaView with edges={['top', 'bottom']} to apply the top safe area inset. The shim (SafeAreaViewWithHookTopInset) turns off the native top inset and re-applies it via a hook-based paddingTop. With the transparentModal presentation mode used by this screen, the hook-based top inset was intermittently not applied, causing the header to render too high.

Fix: Follow the same proven pattern used by PerpsOrderHeader — apply the top inset directly to the header view using useSafeAreaInsets(), and only use SafeAreaView for the bottom edge. This is deterministic and does not depend on the shimmed SafeAreaView lifecycle for transparent modals.

Changelog

CHANGELOG entry: Fixed TPSL page header overlapping the status bar area

Related issues

Fixes: TAT-3213

Manual testing steps

Feature: TPSL page header alignment

  Scenario: user creates a TPSL from the order screen
    Given the user is on the Perps order screen with an asset selected

    When user taps the TPSL / Auto close button
    Then the TPSL page opens with the header properly below the status bar / notch area

  Scenario: user edits a TPSL for an open position
    Given the user has an open Perps position with or without existing TP/SL values

    When user taps the Auto close / Edit TPSL button on the position
    Then the TPSL page opens with the header properly below the status bar / notch area

  Scenario: user repeatedly opens and closes the TPSL page
    Given the user is on the Perps order screen

    When user opens and closes the TPSL page multiple times
    Then the header is consistently aligned below the safe area every time

Screenshots/Recordings

Before

https://consensys.slack.com/archives/C092T3GPHQD/p1779353500168619

After

Simulator Screenshot - iPhone 17 Pro Max - 2026-05-21 at 11 40 56

Header is consistently positioned below the safe area.

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Note

Low Risk
Low risk UI layout change limited to safe-area handling in the Perps TPSL screen; no business logic or data flow changes.

Overview
Fixes an intermittent layout issue where the Perps TPSL header could render under the status bar/notch.

PerpsTPSLView now uses useSafeAreaInsets() to add top padding directly on the header, and updates SafeAreaView to only apply the bottom safe area (edges={['bottom']}) so top inset behavior is deterministic in modal presentation.

Reviewed by Cursor Bugbot for commit f3dd563. Bugbot is set up for automated code reviews on this repo. Configure here.

The shimmed SafeAreaView intermittently fails to apply the top inset
on transparentModal screens, causing the header to overlap the
status bar. Use useSafeAreaInsets hook on the header directly,
matching the pattern used by PerpsOrderHeader.
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-perps Perps team label May 21, 2026
@michalconsensys michalconsensys changed the title fix(perps): apply safe area top inset directly to TPSL header fix(perps): apply safe area top inset directly to TPSL header cp-7.78.0 May 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The change is a focused UI/layout fix in PerpsTPSLView.tsx:

  1. Removes 'top' from SafeAreaView edges and replaces it with manual top padding via useSafeAreaInsets hook
  2. This is a cosmetic safe area handling fix — no business logic, state, or API changes

Tags selected:

  • SmokePerps: Directly tests the Perps functionality including the TP/SL view that was modified
  • SmokeWalletPlatform: Per tag description, Perps views (headers, lists, full views) embedded in Trending affect this tag — the PerpsTPSLView header was modified
  • SmokeConfirmations: Per SmokePerps tag description, when selecting SmokePerps, also select SmokeConfirmations (Add Funds deposits are on-chain transactions)

No other tags are needed as this change is isolated to the Perps TP/SL view layout and doesn't affect accounts, identity, network, browser, snaps, swap, or other flows.

Performance Test Selection:
This is a minor UI layout change using useSafeAreaInsets for safe area padding adjustment. It does not affect rendering performance, data loading, state management, or any performance-critical paths. No performance tests are warranted.

View GitHub Actions results

@michalconsensys michalconsensys marked this pull request as ready for review May 21, 2026 09:41
@michalconsensys michalconsensys requested a review from a team as a code owner May 21, 2026 09:41
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.14%. Comparing base (66f0cb2) to head (f3dd563).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...nts/UI/Perps/Views/PerpsTPSLView/PerpsTPSLView.tsx 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #30503   +/-   ##
=======================================
  Coverage   82.13%   82.14%           
=======================================
  Files        5488     5490    +2     
  Lines      147743   147787   +44     
  Branches    33969    33986   +17     
=======================================
+ Hits       121353   121397   +44     
  Misses      18084    18084           
  Partials     8306     8306           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@michalconsensys michalconsensys enabled auto-merge May 21, 2026 10:34
@michalconsensys michalconsensys added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 1635a36 May 21, 2026
329 of 366 checks passed
@michalconsensys michalconsensys deleted the fix/tpsl-header-safe-area branch May 21, 2026 11:14
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants