@onekeyfe/react-native-native-list 6.7.0-alpha.363 → 6.7.0-alpha.366

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -188,6 +188,11 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
188
188
  v.text = ""
189
189
  v.layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
190
190
  v.setOnClickListener(null)
191
+ // setOnClickListener(null) leaves the view clickable, and a clickable
192
+ // child consumes the touch, so a tap on a row value such as a network
193
+ // balance never reached the row click (OK-65494). showTrailing enables
194
+ // the click again only for a text accessory that carries an action.
195
+ v.isClickable = false
191
196
  v.background = null
192
197
  v.setPadding(0, 0, 0, 0)
193
198
  // Legacy trailing text: END gravity, one line, no ellipsis.
@@ -410,11 +415,13 @@ internal class NativeListAccessoryStack(context: android.content.Context, val fo
410
415
  TextViewCompat.setLineHeight(view, dp(if (primary) 24 else 20))
411
416
  textColor?.let(view::setTextColor)
412
417
  view.visibility = VISIBLE
413
- if (!actionKey.isNullOrEmpty()) {
418
+ val clickActionKey = actionKey?.takeIf(::isNativeListTrailingTextClickable)
419
+ view.isClickable = clickActionKey != null
420
+ if (clickActionKey != null) {
414
421
  view.setOnClickListener {
415
422
  (tag as? NativeListItem)
416
423
  ?.takeUnless { item -> item.json.optBoolean("disabled", false) }
417
- ?.let { item -> emitAction(item, actionKey, null, view, "trailingAccessory", index) }
424
+ ?.let { item -> emitAction(item, clickActionKey, null, view, "trailingAccessory", index) }
418
425
  }
419
426
  }
420
427
  }
@@ -27,6 +27,13 @@ internal fun isNativeListWholeRowInteractive(
27
27
  pressDisabled = pressDisabled,
28
28
  )
29
29
 
30
+ /**
31
+ * A trailing text accessory (value, value pair, progress, radio, switch) owns its
32
+ * tap only when it carries an action key; otherwise the touch belongs to the row
33
+ * press, so a value such as a network balance is part of the row's hit area.
34
+ */
35
+ internal fun isNativeListTrailingTextClickable(actionKey: String?): Boolean = !actionKey.isNullOrEmpty()
36
+
30
37
  internal fun resolveNativeListSelectorBackgroundColor(
31
38
  rowType: String,
32
39
  styleBackgroundColor: String?,
@@ -40,4 +40,13 @@ class NativeListPressPolicyTest {
40
40
  },
41
41
  )
42
42
  }
43
+
44
+ // OK-65494: a row value such as a network balance is part of the row's hit
45
+ // area; only a text accessory with an action key handles its own tap.
46
+ @Test
47
+ fun trailingTextOwnsItsTapOnlyWithAnAction() {
48
+ assertEquals(false, isNativeListTrailingTextClickable(null))
49
+ assertEquals(false, isNativeListTrailingTextClickable(""))
50
+ assertEquals(true, isNativeListTrailingTextClickable("network.edit"))
51
+ }
43
52
  }
package/docs/SPEC.md CHANGED
@@ -284,6 +284,26 @@ not establish visual acceptance. Acceptance includes two independent runtimes,
284
284
  two list instances, changed/reset mappings, invalid configuration without partial
285
285
  state, all templates and container text, and retained selection/scroll behavior.
286
286
 
287
+ ### Trailing text accessory hit area (OK-65494)
288
+
289
+ Status: implemented on iOS and Android. iOS XCTest
290
+ (`NativeListAccessoryStackTests`) checks the control state and hit test, Android
291
+ a JVM policy test (`NativeListPressPolicyTest`); iOS Simulator acceptance on the
292
+ app's network selector is recorded in the changelog entry (2026-10-26). Android
293
+ device acceptance pending.
294
+
295
+ A trailing text accessory (`value`, `valuePair`, `progress`, and a `radio` or
296
+ `switch` without an action key) is display only. It MUST NOT own touches: a tap
297
+ on it is a row press, so the whole row, including its value column, is the hit
298
+ area on iOS, Android and Web. Only a text accessory that carries an action key
299
+ (`radio`, `switch`) handles its own tap and emits that action instead of the row
300
+ press. Icon, chevron, menu, drag and checkbox accessories keep their existing
301
+ ownership. iOS implements this by disabling user interaction on the shared
302
+ accessory button when it has no action and restoring it on reset; Android keeps
303
+ the trailing `TextView` non-clickable unless `showTrailing` binds an action
304
+ (`setOnClickListener(null)` alone leaves a view clickable). Web already renders
305
+ an action-less accessory as a `span`, so its click reaches the row.
306
+
287
307
  ## Failures, fallback and limits
288
308
 
289
309
  Snapshot validation rejects malformed/duplicate-key input without partial
@@ -244,6 +244,7 @@ final class NativeListAccessoryStack: UIStackView {
244
244
  button.layer.cornerRadius = 0
245
245
  button.isHidden = true
246
246
  button.isEnabled = true
247
+ button.isUserInteractionEnabled = true
247
248
  button.alpha = 1
248
249
  button.accessibilityIdentifier = nil
249
250
  button.accessibilityLabel = nil
@@ -391,6 +392,11 @@ final class NativeListAccessoryStack: UIStackView {
391
392
  guard accessoryButtons.indices.contains(index), !value.isEmpty else { return }
392
393
  let button = accessoryButtons[index]
393
394
  button.isHidden = false
395
+ // A text accessory without an action is display only. As an enabled
396
+ // UIControl it still claimed the touch, so a tap on a row value such as
397
+ // a network balance never reached the cell and the row did not select
398
+ // (OK-65494). Let those touches fall through to the row press.
399
+ button.isUserInteractionEnabled = action != nil
394
400
  button.setTitle(value, for: .normal)
395
401
  button.setContentHuggingPriority(.required, for: .horizontal)
396
402
  button.setContentCompressionResistancePriority(.required, for: .horizontal)
@@ -409,6 +415,8 @@ final class NativeListAccessoryStack: UIStackView {
409
415
  let secondary = accessory.string("secondary")
410
416
  guard !primary.isEmpty || !secondary.isEmpty else { return }
411
417
  let button = accessoryButtons[index]
418
+ // Value pairs never carry an action; the row owns their touches.
419
+ button.isUserInteractionEnabled = false
412
420
  let text = NSMutableAttributedString()
413
421
  let primaryParagraph = NSMutableParagraphStyle()
414
422
  primaryParagraph.alignment = .right
@@ -0,0 +1,89 @@
1
+ import UIKit
2
+ import XCTest
3
+ @testable import NativeListModule
4
+
5
+ @MainActor
6
+ final class NativeListAccessoryStackTests: XCTestCase {
7
+ private func makeStack(trailing: [[String: Any]]) throws -> NativeListAccessoryStack {
8
+ let stack = NativeListAccessoryStack(frame: CGRect(x: 0, y: 0, width: 160, height: 48))
9
+ let item = try NativeListItem(data: [
10
+ "key": "doge--0",
11
+ "type": "identity",
12
+ "presentation": "networkSelector",
13
+ "height": 48,
14
+ "title": "Dogecoin",
15
+ "trailing": trailing,
16
+ ])
17
+ stack.bind(
18
+ item,
19
+ descriptors: trailing,
20
+ theme: nil,
21
+ style: [:],
22
+ checkboxState: { _, _, fallback in fallback },
23
+ fonts: NativeListFontFamilies()
24
+ )
25
+ stack.layoutIfNeeded()
26
+ return stack
27
+ }
28
+
29
+ private func visibleControl(_ stack: NativeListAccessoryStack) throws -> UIView {
30
+ let control = try XCTUnwrap(stack.firstVisibleControl)
31
+ XCTAssertGreaterThan(control.bounds.width, 0)
32
+ XCTAssertGreaterThan(control.bounds.height, 0)
33
+ return control
34
+ }
35
+
36
+ // OK-65494: a network balance is display only, so a tap on it must reach the
37
+ // cell and select the row instead of stopping at the accessory button.
38
+ func testValueAccessoryLeavesTouchesToTheRow() throws {
39
+ let stack = try makeStack(trailing: [["kind": "value", "text": "¥110.42"]])
40
+ let value = try visibleControl(stack)
41
+ XCTAssertFalse(value.isUserInteractionEnabled)
42
+ XCTAssertTrue(stack.hitTest(value.center, with: nil) === stack)
43
+ }
44
+
45
+ func testValuePairAccessoryLeavesTouchesToTheRow() throws {
46
+ let stack = try makeStack(trailing: [
47
+ ["kind": "valuePair", "primary": "$15.60", "secondary": "0.002 BTC"],
48
+ ])
49
+ let value = try visibleControl(stack)
50
+ XCTAssertFalse(value.isUserInteractionEnabled)
51
+ XCTAssertTrue(stack.hitTest(value.center, with: nil) === stack)
52
+ }
53
+
54
+ func testTextAccessoryWithActionKeepsItsOwnTouches() throws {
55
+ let stack = try makeStack(trailing: [
56
+ ["kind": "radio", "checked": true, "actionKey": "network.select"],
57
+ ])
58
+ let radio = try visibleControl(stack)
59
+ XCTAssertTrue(radio.isUserInteractionEnabled)
60
+ XCTAssertTrue(stack.hitTest(radio.center, with: nil) === radio)
61
+ }
62
+
63
+ func testRebindRestoresTouchOwnershipOfTheReusedButton() throws {
64
+ let stack = try makeStack(trailing: [["kind": "value", "text": "¥110.42"]])
65
+ let value = try visibleControl(stack)
66
+ XCTAssertFalse(value.isUserInteractionEnabled)
67
+ let radioItem = try NativeListItem(data: [
68
+ "key": "doge--0",
69
+ "type": "identity",
70
+ "presentation": "networkSelector",
71
+ "height": 48,
72
+ "title": "Dogecoin",
73
+ ])
74
+ let radio: [[String: Any]] = [["kind": "radio", "checked": false, "actionKey": "network.select"]]
75
+ stack.bind(
76
+ radioItem,
77
+ descriptors: radio,
78
+ theme: nil,
79
+ style: [:],
80
+ checkboxState: { _, _, fallback in fallback },
81
+ fonts: NativeListFontFamilies()
82
+ )
83
+ stack.layoutIfNeeded()
84
+ let reused = try visibleControl(stack)
85
+ XCTAssertTrue(reused === value)
86
+ XCTAssertTrue(reused.isUserInteractionEnabled)
87
+ XCTAssertTrue(stack.hitTest(reused.center, with: nil) === reused)
88
+ }
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "6.7.0-alpha.363",
3
+ "version": "6.7.0-alpha.366",
4
4
  "description": "Template-driven native RecyclerView and UICollectionView for React Native",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -86,8 +86,8 @@
86
86
  "typescript": "^5.9.2"
87
87
  },
88
88
  "peerDependencies": {
89
- "@onekeyfe/react-native-image": "6.7.0-alpha.363",
90
- "@onekeyfe/react-native-native-logger": "6.7.0-alpha.363",
89
+ "@onekeyfe/react-native-image": "6.7.0-alpha.366",
90
+ "@onekeyfe/react-native-native-logger": "6.7.0-alpha.366",
91
91
  "react": "*",
92
92
  "react-native": "*",
93
93
  "react-native-nitro-modules": "0.37.0"