Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS, Fabric): add missing logic for finding touch handler #2193

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Jun 18, 2024

Description

- [RNSScreen touchHandler] method was missing implementation for Fabric, adding it here.

Changes

  • Add category on UIView with code for touch handler finding
  • Use the new category to simplify implementation

Test code and steps to reproduce

Test2118 - tested on both archs & works just fine

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@kkafar kkafar force-pushed the @kkafar/fix-touchable-on-paper branch from abfc9fb to fef6798 Compare June 18, 2024 14:53
Copy link
Member Author

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

Just a note for reviewers.

Comment on lines +10 to +12
#define RNS_TOUCH_HANDLER_ARCH_TYPE RCTSurfaceTouchHandler
#else
#define RNS_TOUCH_HANDLER_ARCH_TYPE RCTTouchHandler
Copy link
Member Author

Choose a reason for hiding this comment

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

I tried using typedefs instead of macros here, but stumbled upon issues with nullability (section about "audited regions") and had unexpected issues doing any casting for typedef'd types -> went for macros.

@kkafar kkafar requested review from tboba and WoLewicki June 18, 2024 14:57
@kkafar kkafar changed the title fix(iOS, Fabric): add missing code for finding touch handler fix(iOS, Fabric): add missing logic for finding touch handler Jun 18, 2024
Copy link
Member

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tboba tboba left a comment

Choose a reason for hiding this comment

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

LGTM! Just left two comments out there 👍

Copy link
Member

Choose a reason for hiding this comment

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

If we're keeping in this file only TouchHandler-specific code, I would call this file as UIView+RNSTouchHandlers.

Copy link
Member Author

Choose a reason for hiding this comment

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

I used already existing category name - RNSUtility (we have already introduced this one), and I think it is better suited for future, as putting any more utility methods in RNSTouchHandlers wouldn't make sense. It's again the matter of taste... I'll keep current version, but thanks for suggestion!

[touchHandler rnscreens_cancelTouches];
}
#endif // RCT_NEW_ARCH_ENABLED
[[self rnscreens_findTouchHandlerInAncestorChain] rnscreens_cancelTouches];
Copy link
Member

Choose a reason for hiding this comment

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

Can we do something like:

RNS_TOUCH_HANDLER_ARCH_TYPE *touchHandler = [self rnscreens_findTouchHandlerInAncestorChain];
[touchHandler rnscreens_cancelTouches];

to improve readability?

Copy link
Member Author

Choose a reason for hiding this comment

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

I find it quite opposite 😄 I'm mean the redundant variable strikes me => I'll stay by current version as this is taste related, but thanks.

@kkafar kkafar merged commit dc7c780 into main Jun 20, 2024
5 checks passed
@kkafar kkafar deleted the @kkafar/fix-touchable-on-paper branch June 20, 2024 09:50
alduzy pushed a commit that referenced this pull request Jun 28, 2024
## Description

`- [RNSScreen touchHandler]` method was missing implementation for
Fabric, adding it here.

## Changes

- **Add category on UIView with code for touch handler finding**
- **Use the new category to simplify implementation**

## Test code and steps to reproduce

`Test2118` - tested on both archs & works just fine

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
kkafar added a commit that referenced this pull request Jul 2, 2024
…sted stack (#2223)

## Description

In #2193 I've made a mistake - on Paper, when there is no touch handler
held in `_touchHandler` field I've started
lookup for touch handler in ancestor chain from `self` -> which leads to
infinite loop when swiping back in nested-stack navigation scenario.


## Changes

* Started lookup from superview.


## Test code and steps to reproduce

`Test2223`

1. Navigate to NestedStack.
2. Navigate to NestedStack details screen.
3. Use swipe gesture to go-back


W/o this PR the application will crash hitting infinite loop.

Also test that this behaviour remains fixed:

* #2131

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
…re-mansion#2193)

## Description

`- [RNSScreen touchHandler]` method was missing implementation for
Fabric, adding it here.

## Changes

- **Add category on UIView with code for touch handler finding**
- **Use the new category to simplify implementation**

## Test code and steps to reproduce

`Test2118` - tested on both archs & works just fine

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
…sted stack (software-mansion#2223)

## Description

In software-mansion#2193 I've made a mistake - on Paper, when there is no touch handler
held in `_touchHandler` field I've started
lookup for touch handler in ancestor chain from `self` -> which leads to
infinite loop when swiping back in nested-stack navigation scenario.


## Changes

* Started lookup from superview.


## Test code and steps to reproduce

`Test2223`

1. Navigate to NestedStack.
2. Navigate to NestedStack details screen.
3. Use swipe gesture to go-back


W/o this PR the application will crash hitting infinite loop.

Also test that this behaviour remains fixed:

* software-mansion#2131

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
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