fix: StoryView was interfering with scroll gestures #440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some touch interactions, especially scrolling, were not working well after
StoryView
started wrapping its contents inTouchableWithoutFeedback
.What I did
Switch out the use of
TouchableWithoutFeedback
and prefer to useonStartShouldSetResponder
to listen for touch interactions, dismiss the keyboard, and then decline to handle the touch interaction. This means that the interaction attempt is handed to the next component in the hierarchy to handle.Unlike
Touchable...
which wants to handle the interaction, and ends up interfering with interactions.How to test
There are a few new stories under the "Interaction Examples" section in the storybook. They all work now, but you can see the broken behaviour by making the following local modifications in
StoryView.tsx
:onStartShouldSetResponder={dismissOnStartResponder}
Most of the interactions are unaffected, but the "Scrolling" story will not be scrollable unless the keyboard is open.
If you remove both the
TouchableWithoutFeedback
and theonStartShouldSetResponder
prop, then the scrolling interaction views will dismiss the keyboard on tap, but the "Static" story won't.