Question T16858
Visible to All Users

onOpenFileChooser event Angular

created a year ago (modified a year ago)

Hello Team,

I am writing to seek assistance with an issue I've encountered while utilizing the library within my Angular application.

The problem arises when I interact with the image pick functionality. Specifically, when I engage with the image picker (multi-image selection), the expected event (`onOpenFileChooser`) is triggered, as intended. In accordance with my implementation, this event is designed to open my custom file storage.

Below is a snippet of the relevant code for your reference:

JavaScript
private setupFileChooserListener(): void {   this.creator.onOpenFileChooser.add((\_, options) => {     this.subscriptions.push(       this.editorImageUploadService.browseImage().subscribe(async (imageURL: string) => {         try {           if (!imageURL) return;           const file: File | null = await UrlToFileConverter.fetchImageFileFromUrl(imageURL);           if (!file) {             console.error('Failed to create File object.');             return;           }           options.callback(\[file\]);         } catch (error: any) {           console.error('Error in file chooser listener:', error);         }       })     );   }); }

However, the issue arises when I initially click on the image chooser (single choice - after implementing the fix you provided to trigger the event). Upon the first event (click), which triggers the `onOpenFileChooser`, it opens the default file explorer instead of my custom one. Subsequent clicks behave as expected, opening my custom storage.

To summarize the difference in behavior:

- The image picker consistently triggers my custom logic upon the first event.
- In contrast, the image chooser initially triggers the default file explorer and only starts triggering my custom logic from the second event onward.

Ideally, I would like the image chooser to behave consistently like the image picker, triggering my custom logic from the first event itself.

I would greatly appreciate any insights or guidance you could provide to help resolve this issue. Thank you for your assistance.

Thank you,
Best regards
Stavros

Comments (1)

    Hello Stavros,
    Thank you for the detailed explanation. I believe we addressed this issue in the upcoming maintenance update (v1.9.130). Once it is ready, I'll check it on my end and let you know the result.

    Please stay tuned.

    Answers approved by surveyjs Support

    created a year ago

    Hi Stavros,
    We fixed this issue in v1.9.130: View CodeSandbox. Please upgrade your SurveyJS version.

    Should you have any further questions, please do let us know.

    Thanks