0

I am working on Outlook Web Add-in developing using ReactJs, I have compose task-pane Add-In where I'm using this file uploader. So whenever I tried to upload any file of any size (small or large) the taskpane crashes and restarting Add-In. And mostly it happens uploading first time any file. Am I doing something wrong in code or is it any Outlook issue?

I aslo tried some react npm package for dropzone which also getting this same error. I have attached screenshot of error, Event of outlook alert and code of my file uploader.


Windows 10 Home (19041.388) Outlook Version 2007(Build 13029.20344 Click-to-Run)

AddIn Error

Event Viewer Error Report

import * as React from "react";
import { MessageBar } from "office-ui-fabric-react/lib/MessageBar";

interface DocumentUploaderProps {
    handleOnDropFiles: (files: any, callback?: any) => void;
}

export default class DocumentUploader extends React.Component<DocumentUploaderProps> {
    inputFileRef;
    constructor(props) {
        super(props);
        this.inputFileRef = React.createRef();
    }
    dragOver = (e) => {
        e.preventDefault();
    }

    dragEnter = (e) => {
        e.preventDefault();
    }

    dragLeave = (e) => {
        e.preventDefault();
    }

    fileDrop = (e) => {
        e.preventDefault();
        const files = e.dataTransfer.files;
        this.props.handleOnDropFiles(files, () => this.inputFileRef.current.value = "");
    }
    onClickDropzone = () => {
        this.inputFileRef.current.click();
    }
    render() {
        return (
            <div className="ms-Grid-row">
                <div className="ms-Grid-col ms-sm12">
                    <div className="dz-container">
                        <section
                            className="dropzone"
                            onDragOver={this.dragOver}
                            onDragEnter={this.dragEnter}
                            onDragLeave={this.dragLeave}
                            onDrop={this.fileDrop}
                            onClick={this.onClickDropzone}
                        >
                            <div>
                                <input
                                    ref={this.inputFileRef}
                                    type="file"
                                    style={{ display: "none" }}
                                    onChange={(e) => this.props.handleOnDropFiles(e.target.files, () => this.inputFileRef.current.value = "")}
                                    multiple
                                />
                                <p className="upload-icon">
                                    <i className="fas fa-file-upload" aria-hidden="true"></i>
                                </p>
                                <p className="ms-fontWeight-bold dropzone-msg">Click or drag files here</p>
                            </div>
                        </section>
                    </div>
                </div>
            </div>
        );
    }
}
Mohnish Karhade
  • 99
  • 1
  • 11
  • Try replacing this.inputFileRef everywhere to this.inputFileRef.current – simbathesailor Aug 28 '20 at 07:34
  • I tried replacing `this.inputFileRef.current` but still its crashing, but when I use simple native input type=file **without** dropzone div and not hiding file input and mimicking file input click event to dropzone div click than it never crash – Mohnish Karhade Aug 28 '20 at 10:35
  • Can you the update the code above with latest one that you tried – simbathesailor Aug 28 '20 at 10:37
  • For now i have used `` and it is hidden using `visible:0` CSS and fixed overlapped upon dropzone div. So i have fixed like this. – Mohnish Karhade Aug 29 '20 at 06:21
  • We are unable to reproduce this issue. on our end. A good thing would be to check whether you hit this issue with Vanilla JavaScript (no React JS). If yes, we would you like to get a full but simple repro script. You could leverage ScriptLab add-in from store to build the repro. – Outlook Add-ins Team - MSFT Sep 05 '20 at 20:57

1 Answers1

1

We were able to reproduce this issue in-house using data from this post and this related post. We have fixed the bug and the fix should be available in build 16.0.13603.10000 or later. When an updated build is available depends on the release channel a customer is on.