Question T17873
Visible to All Users

Disable File question DnD

created 9 months ago

Hello, is there a way to disable the DnD of a file question? Leaving just the option of uploading a file when clicking on the Upload button.

Answers approved by surveyjs Support

created 9 months ago

Hello Amit,
We don't have this functionality.
Why do you need to disable this functionality?

Thank you,
Andrew
SurveyJS Team

    Comments (2)

      There is a requirement to disable DnD.

      I managed to do this as follows:

      JavaScript
      const onAfterRenderQuestion = useCallback( (_: Model, { question }: AfterRenderQuestionEvent) => { if (isFile(question)) { const file = question as unknown as QuestionFileModel; //Disable all file DnD events file.onDragOver = (e) => e.preventDefault(); file.onDragLeave = (e) => e.preventDefault(); file.onDragEnter = (e) => e.preventDefault(); file.onDrop = (e) => e.preventDefault(); } }, [] );

        It may work.

        Thank you,
        Andrew
        SurveyJS Team