Skip to content

fix(chat): Preserve message text when sharing media from picker#2367

Merged
Ivansss merged 1 commit intonextcloud:mainfrom
luflow:fix/preserve-text-when-sharing-media
Jan 29, 2026
Merged

fix(chat): Preserve message text when sharing media from picker#2367
Ivansss merged 1 commit intonextcloud:mainfrom
luflow:fix/preserve-text-when-sharing-media

Conversation

@luflow
Copy link
Copy Markdown
Contributor

@luflow luflow commented Jan 26, 2026

Summary

  • Fixes an issue where text typed in the chat input field was lost when selecting media to share
  • The text is now transferred to the ShareConfirmationViewController as the media caption
  • Matches the existing behavior for pasted media content

Problem

When a user had already typed text in the chat input field and then selected an image, video, or document to share via the picker, the text was being wiped/cleared instead of being used as the caption for the shared media.

Solution

Added calls to setChatMessage() in the picker delegate methods to transfer the existing text to the ShareConfirmationViewController before clearing the main input field. This mirrors the implementation that already exists in didPasteMediaContent().

Affected picker delegates:

  • PHPickerViewControllerDelegate (photo library)
  • UIImagePickerControllerDelegate (camera)
  • UIDocumentPickerViewControllerDelegate (files)

If the user cancels the share, the text is restored to the chat input (this was already implemented in shareConfirmationViewControllerDidCancel).

Test plan

  • Type some text in the chat input
  • Tap the attachment button and select "Photo Library"
  • Select an image
  • Verify the text appears in the caption field of the share confirmation view
  • Cancel the share and verify the text is restored to the chat input
  • Repeat for camera and file picker

When a user had already typed text in the chat input field and then
selected an image, video, or document to share, the text was being
lost instead of being used as the caption for the shared media.

This fix transfers the existing chat message text to the
ShareConfirmationViewController before clearing the input field,
matching the behavior that already exists for pasted media content.

If the user cancels the share, the text is restored to the chat input.

Affected picker delegates:
- PHPickerViewController (photo library)
- UIImagePickerController (camera)
- UIDocumentPickerViewController (files)

Signed-off-by: Florian Ludwig <florian.ludwig@uninow.de>
@luflow luflow force-pushed the fix/preserve-text-when-sharing-media branch from 6cd7fc2 to 02b6b3e Compare January 26, 2026 13:00
Copy link
Copy Markdown
Member

@Ivansss Ivansss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice :)
Thanks for this PR!

Copy link
Copy Markdown
Collaborator

@SystemKeeper SystemKeeper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@Ivansss Ivansss merged commit cdcf963 into nextcloud:main Jan 29, 2026
10 checks passed
@luflow luflow deleted the fix/preserve-text-when-sharing-media branch January 29, 2026 15:54
@github-actions
Copy link
Copy Markdown

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants