Skip to content

Improve attachments previews#154

Open
djhi wants to merge 18 commits intomainfrom
attachments-preview
Open

Improve attachments previews#154
djhi wants to merge 18 commits intomainfrom
attachments-preview

Conversation

@djhi
Copy link
Contributor

@djhi djhi commented Feb 2, 2026

Problem

  • The FakeRest demo does not show previews for image attachments.
  • The input for attachments does not show previews for image attachments.

Solution

  • Create a custom field for attachments that display either an image or a link.
  • Fix FakeRest DataProvider so that is has the same format as the Supabase one and keep the attachment mimetype

Note form:
image

Note list:
image

How To Test

For both demos (fakerest and supabase):

  • Open or create a contact
  • Add a note with some attachments (both images and simple documents)
  • Check that images have previews
  • Save the note
  • Check that the images have previews in the notes list

Additional Checks

Also, please make sure to read the contributing guidelines.

@djhi djhi added the WIP label Feb 2, 2026
@djhi djhi added RFR and removed WIP labels Feb 2, 2026
@Madeorsk Madeorsk self-requested a review February 3, 2026 08:59
@Madeorsk Madeorsk marked this pull request as ready for review February 3, 2026 08:59
Copy link
Contributor

@Madeorsk Madeorsk left a comment

Choose a reason for hiding this comment

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

Looks great!
But it isn't showing in the note edition form 😔😔

image

@WiXSL WiXSL self-requested a review February 4, 2026 15:53
Copy link
Collaborator

Choose a reason for hiding this comment

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

The preview click uses window.open(attachment.src, "_blank"), and browsers block navigating a top-level frame to data: (“Not allowed to navigate top frame to data URL”), so it opens a blank tab.
This doesn’t happen with Supabase (http URLs).

Copy link
Collaborator

@WiXSL WiXSL Feb 4, 2026

Choose a reason for hiding this comment

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

I know this is not related to this PR. but still

Copy link
Collaborator

Choose a reason for hiding this comment

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

1- Edit a Note, add an image and save (You see the preview of the image)
2- Edit the same Note again an add a file (not an image)
Result: Yo see boath items but no preview of the image

With Fakerest or Supabase is the same.

You also cannot click the image to enlarge it

Copy link
Contributor

@Madeorsk Madeorsk left a comment

Choose a reason for hiding this comment

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

Looks good, but needs rebase

@djhi djhi requested a review from WiXSL February 10, 2026 14:10
Copy link
Collaborator

Choose a reason for hiding this comment

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

1- Edit a Note, add an image and save (You see the preview of the image)
2- Edit the same Note again an add a file (not an image)
Result: Yo see boath items but no preview of the image

With Fakerest or Supabase is the same.

You also cannot click the image to enlarge it

@djhi
Copy link
Contributor Author

djhi commented Feb 11, 2026

@WiXSL I can't reproduce the issue with Supabase. I fixed the fakerest implementation

@WiXSL
Copy link
Collaborator

WiXSL commented Feb 11, 2026

@WiXSL I can't reproduce the issue with Supabase. I fixed the fakerest implementation

Its fix now.
But clicking on attachments does not open nor download them. Is this expected?

@djhi
Copy link
Contributor Author

djhi commented Feb 11, 2026

@WiXSL I can't reproduce the issue with Supabase. I fixed the fakerest implementation

Its fix now. But clicking on attachments does not open nor download them. Is this expected?

I can't reproduce this on neither supabase nor fakerest. When are you trying to open attachments? If it's in the form, I didn't add any code to do it indeed. However, in the note "show" view, it works

@WiXSL
Copy link
Collaborator

WiXSL commented Feb 11, 2026

@WiXSL I can't reproduce the issue with Supabase. I fixed the fakerest implementation

Its fix now. But clicking on attachments does not open nor download them. Is this expected?

I can't reproduce this on neither supabase nor fakerest. When are you trying to open attachments? If it's in the form, I didn't add any code to do it indeed. However, in the note "show" view, it works

I've try it with supabase and everything worked.
With Fakerest is the problem. I've edited a note. Add an atachement, save the note, and when I click on the attachements, they wont open or download

@djhi
Copy link
Contributor Author

djhi commented Feb 12, 2026

@WiXSL I can't reproduce the issue with Supabase. I fixed the fakerest implementation

Its fix now. But clicking on attachments does not open nor download them. Is this expected?

I can't reproduce this on neither supabase nor fakerest. When are you trying to open attachments? If it's in the form, I didn't add any code to do it indeed. However, in the note "show" view, it works

I've try it with supabase and everything worked. With Fakerest is the problem. I've edited a note. Add an atachement, save the note, and when I click on the attachements, they wont open or download

I can't reproduce this issue. With both FakeRest and Supabase, I can open the attachments by clicking them.

Copy link
Collaborator

@WiXSL WiXSL left a comment

Choose a reason for hiding this comment

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

I can't reproduce this issue. With both FakeRest and Supabase, I can open the attachments by clicking them.

Mmm, I still can with Fakerest in Chrome v145.

Another issue:
1- Goto Deals, and add a new note
2- Add an image as attachment (you see the preview)
3- Save the new note

Result: You no longer see the preview in the new note

Screenshot of Atomic CRM

import type { AttachmentNote, ContactNote, DealNote } from "../types";
import { isImageMimeType } from "./isImageMimeType";

export const NoteAttachments = ({ note }: { note: ContactNote | DealNote }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Now this component seems to overlap with AttachmentField. When should we use one or the other? It's not clear.

Copy link
Collaborator

@WiXSL WiXSL Feb 18, 2026

Choose a reason for hiding this comment

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

AttachmentField renders a single attachment record, while NoteAttachments renders the note.attachments[] collection.
I clarified that distinction in the JSDoc.

@slax57 slax57 self-requested a review February 18, 2026 17:11
Copy link
Collaborator

@slax57 slax57 left a comment

Choose a reason for hiding this comment

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

Other than that it works great! 💪

@WiXSL WiXSL force-pushed the attachments-preview branch from 5273570 to b84885a Compare February 19, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments