-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Return false if gesture recognizers are present but all disabled #3377
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
Changes from 1 commit
2ea33d7
e18bd81
497bafe
17be2e1
e902658
80c7cf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,10 +64,24 @@ - (BOOL)shouldHandleTouch:(RNGHUIView *)view | |
| return button.userEnabled; | ||
| } | ||
|
|
||
| // Certain subviews such as RCTViewComponentView have been observed to have disabled | ||
| // accessibility gesture recognizers such as _UIAccessibilityHUDGateGestureRecognizer, | ||
| // ostensibly set by iOS. Such gesture recognizers cause us to return early, despite | ||
| // the returned view not actually responding to touches. This in turn breaks button | ||
| // touch handling. Therefore, as a bandaid we can check to ensure we don't return | ||
| // true here if the only gesture recognizers we have are all disabled. | ||
| BOOL hasEnabledGestureRecognizer = false; | ||
| for (UIGestureRecognizer *gestureRecognizer in view.gestureRecognizers) { | ||
|
||
| if (gestureRecognizer.isEnabled) { | ||
| hasEnabledGestureRecognizer = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| #if !TARGET_OS_OSX | ||
| return [view isKindOfClass:[UIControl class]] || [view.gestureRecognizers count] > 0; | ||
| return [view isKindOfClass:[UIControl class]] || hasEnabledGestureRecognizer; | ||
| #else | ||
| return [view isKindOfClass:[NSControl class]] || [view.gestureRecognizers count] > 0; | ||
| return [view isKindOfClass:[NSControl class]] || hasEnabledGestureRecognizer; | ||
| #endif | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if "return early" is correct in that case
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is incorrect. In my case, the handler for a touch returned by this algorithm was the native representation of
<View accessible accessibilityRole="button"><Text>Static Text</Text></View>. It didn't have any valid tap gesture recognizers to handle touch events, but it was still chosen by this algorithm to be the view which "shouldHandleTouch"If the algorithm does not return this child view "early", it instead traverses up to the parent
RNGestureHandlerButtonand returns the parent view, which does have gesture handlers due to, in this case, myBorderlessButton'sonPress, which faithfully gets invoked on tapSo, I think this algorithm should not return a child view which happens to have two disabled accessibility gesture recognizers, which were mysteriously added from some unknown source, just because the number of gesture recognizers is greater than zero. Instead, I think it should ignore these disabled gesture recognizers when determining which view should handle touch, so that the parent
RNGestureHandlerButtoncan instead be returned and handle touchesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. What I meant was that the way it is phrased in this comment suggests something like early return in this specific function, not in the whole process.
My guess is that they are added because of
ViewwithaccessibilityRole="button", but I have not checked that yet.Anyway, I think that we should rephrase this comment when we have more information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do you use
Textfrom React Native, or from Gesture Handler?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rephrase the comment to clarify. I find it odd that only in certain scenarios do certain
Views get these accessibility tap gestures added to themAnd, I'm using
Textfrom React Native, how would I importTextfrom Gesture Handler? I'm seeingModule '"react-native-gesture-handler"' has no exported member 'Text'when I tryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I remember
Textcomponent was introduced form 2.22. I asked because that could explain why those views have additional gesture recognizers.I've checked example with only
Viewwith propsaccessibleandaccessibilityRole="button"and it seems that it doesn't have any additional recognizer by defaultThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... Using
Textfrom RNGH 2.22 actually causes the button to not be tappable at all, as in the following:According to the debugger, the
RCTParagraphTextViewhas aRNDummyGestureRecognizerinitially, even before taking the steps which produce the bug in React Native'sTextThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what I meant by:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it — I’d thought you might have been suggesting that NOT using that particular Text might explain why I was seeing additional gesture recognizers