Commit da2c028
authored
fix(Android): implement ReactPointerEventsView to prevent header config from intercepting touches (#2796)
## Description
Closes #2794
We set `visibility = GONE` for the header config in HostTree (HT),
however this only prevents the Android framework from setting header
config frame,
and does not prevent `ReactNative` from setting non-zero frame. When it
has non-zero frame, react recognizes it as a touch target.
## Changes
I've implemented `ReactPointerEventsView` (returning `box-none`) making
sure that RN won't treat it as touch target.
I considered another approach - setting the frame to zero or not letting
react native to set the frame on the view - it also works,
however requires cumbersome implementation on Android API level < 29,
since `suppressLayout` method is available since 29.
On lower API levels you can not really ignore the frame - you can call
`layout` with 0 width in `onLayout` of the header config...
## Test code and steps to reproduce
`HeaderOptions` screen in `Example` app.
Tested it on both architectures & with `headerShown: false/true`.
## Checklist
- [ ] Ensured that CI passes1 parent 91400bc commit da2c028
4 files changed
Lines changed: 16 additions & 5 deletions
File tree
- android/src
- main/java/com/swmansion/rnscreens
- versioned/pointerevents
- 77/com/swmansion/rnscreens
- latest/com/swmansion/rnscreens
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
| 483 | + | |
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
546 | | - | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
547 | 553 | | |
548 | 554 | | |
549 | 555 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
0 commit comments