Skip to content

feat(native-list): add native context menus to content rows - #351

Open
limichange wants to merge 3 commits into
mainfrom
feat/native-list-context-menu
Open

limichange wants to merge 3 commits into
mainfrom
feat/native-list-context-menu

Conversation

@limichange

@limichange limichange commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

OneKey's Market Favorites list opens a JS overlay ("Move to top" / "Remove") on long press. This adds a native long-press menu to NativeList, so the platform draws it. The contract is the same for every content row, so another list can adopt it later with row data and an onRowAction case, without a native release.

  • Contract: contextMenu?: { title?, actions } on identity, rail, activity, message, data, media tile, metric card and market rows. 1 to 8 entries with actionKey, title, iosSystemImage?, icon?, destructive?, disabled?. It is also a patch field; null clears it. Section headers, actions, button groups, system rows and wallet groups reject it.
  • iOS 16+: UICollectionView context menu. The row's own cell is the lifted preview: an edge-to-edge row lifts as an inset rounded card, a narrower row in its own shape. A dark fill rises one tone while lifted; without that, the card and the dimmed page were #0f0f0f and #0f0f14.
  • Android: the row's platform long click (system timeout, slop, haptics, accessibility action) opens a themed popup next to the row, below it when it fits and above otherwise. The popup stays inside the window and its entries scroll when they do not fit. The adapter wires it on list rows only, so a row nested in a wallet group never opens one. PopupMenu is not used: under the app theme it stays light and square-cornered in dark mode.
  • Result: a chosen entry emits one onRowAction with the row's key and the entry's actionKey, without an anchor.
  • Updates: patches and snapshot replacements keep an open menu while its row still offers one through the same renderer. A removed row closes it, and an update that closes the menu also drops a choice still waiting for the Android exit animation.
  • Precedence: whole-row reorder and nested controls (buttons, badges, reorder handles) keep their own long press. Otherwise a presented menu replaces the row's longPressActionKey.
  • iOS 15 and Web ignore the field and keep longPressActionKey, so consumers send both.
  • On Android the long click now lives in the base row. Identity rows' longPressActionKey uses the same listener and keeps its behavior.
  • SPEC ("Native row context menu"), ROW_TEMPLATES and CHANGELOG are updated.

Validation

  • Jest: 13 suites, 662 tests. tsc -b, test integrity and git diff --check pass. ESLint reports the same 4 Prettier errors in validation.test.ts as main.
  • Android unit tests: 15 suites, 61 tests, including NativeListContextMenuActionsTest and NativeListContextMenuPresentationTest (wired and nested rows, the long-press fallback, popup height in a short window, a chosen entry that runs or is dropped).
  • Swift: NativeListContextMenuTests 6/6 on an iOS 26.5 simulator hosted in the OneKey app. CI's ios-native and ios-xctest passed on the first commit; two icon tests that failed only in the OneKey host pass there.
  • Runtime, built into the OneKey app with the Xcode 27.1 SDK, Market Favorites:
    • iOS 26.5: both actions on token and perps rows (stock rows on an earlier build of this branch), first row with Remove only, outside tap, tap opens the detail, light and dark. Re-applying an identical snapshot and patching the row keep the menu open; removing the row closes it. Hold-then-release on rows without a menu still selects them (checked on an earlier build of this branch).
    • iOS 17.5 (menu, Move to top, Remove, first row, light and dark) and 27.1 on iPhone Duo (menu, Move to top, Remove). 27.0 on iPhone 18 Pro passed the same checks on an earlier build, before the content-row contract and the dark lifted fill.
    • Android API 36: both actions, first row, outside tap, Back, upward placement, light and dark, tap opens the detail, the same data updates, rows exposed as long-clickable to accessibility. An eight-entry menu in a 380dp tall window stays on screen, scrolls, and its last entry emits once.
    • Trending, Stocks, Top coins and Perps on both platforms, each with a one-entry menu.
    • Other lists, this code, with a menu added only for the test: the account list on iOS 26.5 (title, destructive entry, dark mode, its trailing button keeps its own press, a draggable wallet row keeps its reorder) and the Swap token list on Android (one event per choice, disabled entry inert, trailing button and longPressActionKey unchanged).
  • Known gap (in the SPEC): inside the app's collapsible pager UIKit logs "Presenting view controller ... from detached view controller", which "will become a hard exception in a future release". On iOS 26.5, 27.0 and 27.1 it is a log and the menu works. The pager never adds its page view controllers to a parent; that belongs to a separate change.
  • Not verified: hardware and haptics, VoiceOver and TalkBack, iOS 15 and 16, RTL, tablets, grids and horizontal lists, and templates other than market and identity at runtime.

Consumer: OneKeyHQ/app-monorepo#14886 (draft), which bumps the package once this is released.

Content rows (identity, rail, activity, message, data, media tile, metric card
and market) can declare `contextMenu` with 1 to 8 entries. iOS 16+ presents it
with the system context menu and the row's own cell as the lifted preview.
Android opens a themed popup next to the row from the platform long click. A
chosen entry emits one `onRowAction`; iOS 15 and Web ignore the field and keep
`longPressActionKey`.

Snapshot replacements and patches keep an open menu while its row still offers
one through the same renderer; a removed row closes it. Whole-row reorder and
nested controls keep their own long press.
@sidmorizon

Copy link
Copy Markdown
Contributor

@codex review

@sidmorizon

Copy link
Copy Markdown
Contributor

@codex security review

@sidmorizon

Copy link
Copy Markdown
Contributor

Cursor review failed.

Remote error: cursor_permission_denied: HTTP 403 Forbidden: Cloud Agent is not available for free users. Please upgrade to Pro.

@cursor

cursor Bot commented Nov 30, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T11:24:28.774603Z b54b831 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sidmorizon

Copy link
Copy Markdown
Contributor

Devin Cloud review ↗

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: b54b831f04

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b54b831f04

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sidmorizon

Copy link
Copy Markdown
Contributor

The adapter now wires the context menu on its own rows, so a row nested in a
wallet group never opens one, even when it shares a key with a list row.

The Android popup stays inside the window. Entries that do not fit, for example
in landscape or split screen, scroll.
On Android a chosen entry waits for the menu to leave. A snapshot or patch that
invalidated the menu in that time closed the popup before the list took the
update, so the choice was checked against the old rows and still emitted. The
update now drops the waiting choice.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants