diff --git a/src/Common/Upload/Upload.tsx b/src/Common/Upload/Upload.tsx index 3feb4fdfd..6b918f0df 100644 --- a/src/Common/Upload/Upload.tsx +++ b/src/Common/Upload/Upload.tsx @@ -23,7 +23,7 @@ export const Upload: FunctionComponent = ({ }: UploadProps) => { const [selectedFilesTitle, setSelectedFilesTitle] = useState([]); - const fileRef = useRef(); + const fileRef = useRef() as React.MutableRefObject; const onImportLinkKeyPress = (event: KeyboardEvent): void => { if (event.keyCode === Constants.KeyCodes.Enter || event.keyCode === Constants.KeyCodes.Space) { @@ -39,12 +39,14 @@ export const Upload: FunctionComponent = ({ const { files } = event.target; const newFileList = []; - for (let i = 0; i < files.length; i++) { - newFileList.push(files.item(i).name); - } - if (newFileList) { - setSelectedFilesTitle(newFileList); - props.onUpload(event); + if (files) { + for (let i = 0; i < files.length; i++) { + newFileList.push(files[i].name); + } + if (newFileList) { + setSelectedFilesTitle(newFileList); + props.onUpload(event); + } } }; const title = label + " to upload"; diff --git a/src/Explorer/Controls/CommandButton/CommandButtonComponent.tsx b/src/Explorer/Controls/CommandButton/CommandButtonComponent.tsx index 2c0f6f283..e36091482 100644 --- a/src/Explorer/Controls/CommandButton/CommandButtonComponent.tsx +++ b/src/Explorer/Controls/CommandButton/CommandButtonComponent.tsx @@ -114,8 +114,14 @@ export interface CommandButtonComponentProps { } export class CommandButtonComponent extends React.Component { - private dropdownElt: HTMLElement; - private expandButtonElt: HTMLElement; + private dropdownElt: HTMLDivElement | undefined; + private expandButtonElt: HTMLDivElement | undefined; + + constructor(props: CommandButtonComponentProps) { + super(props); + this.dropdownElt = undefined; + this.expandButtonElt = undefined; + } public componentDidUpdate(): void { if (!this.dropdownElt || !this.expandButtonElt) { @@ -135,15 +141,19 @@ export class CommandButtonComponent extends React.Component): boolean { if (event.keyCode === KeyCodes.DownArrow) { - $(this.dropdownElt).hide(); - $(this.dropdownElt).show().focus(); - event.stopPropagation(); - return false; + if (this.dropdownElt) { + $(this.dropdownElt).hide(); + $(this.dropdownElt).show().focus(); + event.stopPropagation(); + return false; + } } if (event.keyCode === KeyCodes.UpArrow) { - $(this.dropdownElt).hide(); - event.stopPropagation(); - return false; + if (this.dropdownElt) { + $(this.dropdownElt).hide(); + event.stopPropagation(); + return false; + } } return true; } @@ -185,8 +195,8 @@ export class CommandButtonComponent extends React.Component { - this.expandButtonElt = ref; + ref={(instance: HTMLDivElement) => { + this.expandButtonElt = instance; }} onKeyDown={(e: React.KeyboardEvent) => this.onLauncherKeyDown(e)} > @@ -198,8 +208,8 @@ export class CommandButtonComponent extends React.Component
{ - this.dropdownElt = ref; + ref={(instance: HTMLDivElement) => { + this.dropdownElt = instance; }} >
diff --git a/tsconfig.strict.json b/tsconfig.strict.json index ee037db87..2d7b7adc2 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -139,7 +139,9 @@ "./src/userContext.test.ts", "src/Common/EntityValue.tsx", "./src/Platform/Hosted/Components/SwitchAccount.tsx", - "./src/Platform/Hosted/Components/SwitchSubscription.tsx" + "./src/Platform/Hosted/Components/SwitchSubscription.tsx", + "./src/Common/Upload/Upload.tsx" + ], "include": [ "src/CellOutputViewer/transforms/**/*",