Skip to content

Commit

Permalink
Wrap draggable long-press handler with useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiddot committed Apr 26, 2022
1 parent ee86986 commit f8690db
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ const BlockDraggable = ( { clientId, children, enabled = true } ) => {
};
}, [] );

const onLongPressDraggable = useCallback( () => {
// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.
RCTAztecView.InputState.blurCurrentFocusedElement();
}, [] );

const animatedWrapperStyles = useAnimatedStyle( () => {
return {
opacity: draggingAnimation.opacity.value,
Expand Down Expand Up @@ -365,10 +370,7 @@ const BlockDraggable = ( { clientId, children, enabled = true } ) => {
: DEFAULT_LONG_PRESS_MIN_DURATION,
android: DEFAULT_LONG_PRESS_MIN_DURATION,
} ) }
onLongPress={ () => {
// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.
RCTAztecView.InputState.blurCurrentFocusedElement();
} }
onLongPress={ onLongPressDraggable }
>
<Animated.View style={ wrapperStyles }>
{ children( { isDraggable: true } ) }
Expand Down

0 comments on commit f8690db

Please sign in to comment.