Fixed stric issues for ErrorHandlingUtils and AccessibleElement

This commit is contained in:
vaidankarswapnil
2021-08-18 16:19:49 +05:30
parent 410f582378
commit 84bc5179c6
4 changed files with 29670 additions and 30 deletions

29666
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -28,10 +28,10 @@ export const getErrorMessage = (error: string | Error = ""): string => {
};
export const getErrorStack = (error: string | Error): string => {
return typeof error === "string" ? undefined : error.stack;
return typeof error === "string" ? "" : error.stack === undefined ? "" : error.stack;
};
const sendNotificationForError = (errorMessage: string, errorCode: number | string): void => {
const sendNotificationForError = (errorMessage: string, errorCode: number | string | undefined): void => {
if (errorCode === HttpStatusCodes.Forbidden) {
if (errorMessage?.toLowerCase().indexOf("sharedoffer is disabled for your account") > 0) {
return;

View File

@@ -2,9 +2,9 @@ import * as React from "react";
import * as Constants from "../../../Common/Constants";
interface AccessibleElementProps extends React.HtmlHTMLAttributes<HTMLElement> {
as: string; // tag element name
onActivated: (event: React.SyntheticEvent<HTMLElement>) => void;
"aria-label": string;
as?: string; // tag element name
onActivated?: (event: React.SyntheticEvent<HTMLElement>) => void;
"aria-label"?: string;
tabIndex?: number;
}
@@ -16,7 +16,9 @@ export class AccessibleElement extends React.Component<AccessibleElementProps> {
if (event.charCode === Constants.KeyCodes.Space || event.charCode === Constants.KeyCodes.Enter) {
event.stopPropagation();
event.preventDefault();
this.props.onActivated(event);
if (this.props.onActivated !== undefined) {
this.props.onActivated(event);
}
}
};
@@ -27,11 +29,15 @@ export class AccessibleElement extends React.Component<AccessibleElementProps> {
const tabIndex = this.props.tabIndex === undefined ? 0 : this.props.tabIndex;
return React.createElement(this.props.as, {
...elementProps,
onKeyPress: this.onKeyPress,
onClick: this.props.onActivated,
tabIndex,
});
return this.props.as !== undefined ? (
React.createElement(this.props.as, {
...elementProps,
onKeyPress: this.onKeyPress,
onClick: this.props.onActivated,
tabIndex,
})
) : (
<></>
);
}
}

View File

@@ -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/ErrorHandlingUtils.ts",
"./src/Explorer/Controls/AccessibleElement/AccessibleElement.tsx"
],
"include": [
"src/CellOutputViewer/transforms/**/*",