Fix typescript strict issues for Upload andnd CommandButtonComponent

This commit is contained in:
vaidankarswapnil
2021-08-31 17:06:03 +05:30
parent 39dd293fc1
commit 445068250f
3 changed files with 35 additions and 21 deletions

View File

@@ -114,8 +114,14 @@ export interface CommandButtonComponentProps {
}
export class CommandButtonComponent extends React.Component<CommandButtonComponentProps> {
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<CommandButtonCompone
private onLauncherKeyDown(event: React.KeyboardEvent<HTMLDivElement>): 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<CommandButtonCompone
<div
className="commandExpand"
tabIndex={0}
ref={(ref: HTMLElement) => {
this.expandButtonElt = ref;
ref={(instance: HTMLDivElement) => {
this.expandButtonElt = instance;
}}
onKeyDown={(e: React.KeyboardEvent<HTMLDivElement>) => this.onLauncherKeyDown(e)}
>
@@ -198,8 +208,8 @@ export class CommandButtonComponent extends React.Component<CommandButtonCompone
</div>
<div
className="commandDropdownContainer"
ref={(ref: HTMLElement) => {
this.dropdownElt = ref;
ref={(instance: HTMLDivElement) => {
this.dropdownElt = instance;
}}
>
<div className="commandDropdown">