question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onLongPress doesnt work on MessageImage

See original GitHub issue

Issue Description

I have a chat where a user can send images and text. I added the onLongPress handler on GiftedChat, it works great for text, but doesnt work for images.

Steps to Reproduce / Code Snippets

Add an image in the chat. Hold long on the image, the onLongPress wont be called.

Expected Results

onLongPress handler will be called for MessageImage same as it is called for MessageText

Additional Information

  • Nodejs version: 14.11.0
  • React version: 16.9.0
  • React Native version: 0.61.5
  • react-native-gifted-chat version: 0.11.3
  • Platform(s) (iOS, Android, or both?): both
  • TypeScript version: 3.9.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
efstathiosntonascommented, Nov 8, 2020

You can pass imageProps like:

    imageProps={{ openImageViewer: openModalAndSetImages }}

in my case i have a custom image modal viewer (no built in LightBox) react-native-image-zoom-viewer :

  const openModalAndSetImages = useCallback((images) => {
    setImageUrls(images);
    setImageViewer(true);
  }, []);

and outside of <GiftedChat>...</GiftedChat> i present the modal:

 <ChatImageModal
        showImageViewer={showImageViewer}
        imageUrls={imageUrls}
        setImageUrls={setImageUrls}
        setImageViewer={setImageViewer}
      />
1reaction
obendevskicommented, Nov 9, 2020

@efstathiosntonas Thanks a ton ! U saved me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with messages rendering a view specific to onLongPress
I am trying to render a View through renderCustomView={this.displayEmojis} for an individual message once a user has activated the ...
Read more >
onLongPress prop not working for image messages #577
While trying to perform onLongPress for messages with image, only react-native-lightbox functions triggers. Is there a work around for this?
Read more >
Supporting Both Tap and Long Press on a Button in SwiftUI
Now the button tap works again — unfortunately the long-press gesture doesn't work anymore. OK, let's use simultaneousGesture to tell SwiftUI that we...
Read more >
Message Components — Stream Chat React Native - Docs
The Message component is the high level component that deals with all the message logic. It doesn't implement any rendering, but delegates that...
Read more >
Drag and drop UI elements in Flutter with Draggable and ...
Dropping an item on the DragTarget widget; Making UI elements draggable on long-press with LongPressDraggable; Flutter drag-and-drop example: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found