Patch keyboard overlap and nested scroll bugs #1
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.
Intro
This PR patches a couple of bugs that I've run into with the
react-native-draggable-flatlist
package.Use case and demo
I'm building a recipe editor UI with a feature for drag-and-drop reordering ingredients and instructions.
demo.mov
Bugs patched
Scroll is broken in NestableScrollContainer
There's an open issue in the repo for this -> computerjazz#497
The workaround that I was able to find is:
PanHandler
inDraggableFlatList
to utilize anenabled
state.tapGesture
that replaces the "drag" function returned to list itemsenabled
state to true when thetapGesture
is pressed down.enabled
to false on press up.I initially tried controlling the
enabled
state from within thedrag
function but was getting some gnarly race conditions.This results in the following behavior:
tapGesture
, thepanGesture
will fail and allow the regular scroll event.tapGesture
will fire simultaneously and set theenabled
state to true. ThepanGesture
will activate and track the pan events.Here's what that looks like within the consuming application:
Inputs are not keyboard aware
I found that neither react-native-keyboard-aware-scroll-view or KeyboardAvoidingView were compatible with the
NestableScrollContainer
.This is worked around by the
useKeyboardListener
hook that is introduced in this PR. It listens to keyboard events and automatically scrolls to prevent the input from being hidden. Note that this only seemed to be necessary on iOS.