Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken behavior: files containing dots in the name #1580

Closed
Goncaloo42 opened this issue Jul 3, 2023 · 8 comments
Closed

Broken behavior: files containing dots in the name #1580

Goncaloo42 opened this issue Jul 3, 2023 · 8 comments
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Milestone

Comments

@Goncaloo42
Copy link

Category

[ ] Enhancement

[ ] Bug

[x ] Question

Related issues? #1022

Version

Please specify what version of the library you are using: [3.9.0]

Expected / Desired Behavior / Question

I'm having an issue using the ListItemAttachments component from your library. Basically after adding and configuring the component on a form inside a SharePoint WebPart, pretty much everything works as expected. BUT one thing that does not behave as expected is when adding attachments that contain one or more dots (".") in the name, the file type icon is not displayed (ex. PDF, Word, etc.)

After researching, I found out that this issue was already addressed here

Can someone help me figure why is it still showing blank icons for me?

Thanks!

@ghost
Copy link

ghost commented Jul 3, 2023

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Jul 3, 2023
@github-actions
Copy link

github-actions bot commented Jul 3, 2023

Thank you for submitting your first issue to this project.

@NishkalankBezawada
Copy link
Contributor

Hello @Goncaloo42,

I was able to resolve this issue. Will be creating a pull request.

image

Below are the attachments,

image

image

Thanks,
Nishkalank

@NishkalankBezawada
Copy link
Contributor

Hello @Goncaloo42,

The solution is as below,

Solution

While loading the attachment preview at method loadAttachmentPreview we call GetFileImageUrl to fetch the previewImageUrl.

The old code is as below,

    const _fileTypes = _file.FileName.split('.');
    const _fileExtension = _fileTypes[1];

And since, the scenario when we have one or more dots (".") in the file name, the _fileExtension which will get the first element of array from _fileTypes

The corrected code is as below

const _fileExtension = _file.FileName.substr(_file.FileName.lastIndexOf('.') + 1);

this change will get the exact extension of the file.

below are the images from my local workbench.

image

image

image

Thanks,
Nishkalank Bezawada

@Goncaloo42
Copy link
Author

Hello @NishkalankBezawada,
Thank you for your reply and your help!

Now I just need to wait for your changes to be live so I can update the reference in my solution, correct?

@NishkalankBezawada
Copy link
Contributor

Hello @NishkalankBezawada,

Thank you for your reply and your help!

Now I just need to wait for your changes to be live so I can update the reference in my solution, correct?

Hej, Well that's true.

//Nishkalank

@joelfmrodrigues
Copy link
Collaborator

@Goncaloo42 many thanks for raising this issue, and many thanks @NishkalankBezawada for the PR.
I have just merged the PR and a new beta version of the package containing the fix should be automatically published in a few minutes.

@joelfmrodrigues joelfmrodrigues added status:fixed-next-drop Issue will be fixed in upcoming release. type:bug and removed Needs: Triage 🔍 labels Jul 6, 2023
@joelfmrodrigues joelfmrodrigues added this to the 3.15.0 milestone Jul 6, 2023
@joelfmrodrigues
Copy link
Collaborator

New release just published, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Projects
None yet
Development

No branches or pull requests

3 participants