fix(ErrorBoundary): Fixing console errors and Improving error logging for better developer experience (#5378)
This commit is contained in:
parent
f6d05bc21c
commit
56c5828b02
@ -39,13 +39,13 @@ export interface ButtonProps
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||||
({ className, variant, size, asChild = false, ...props }, forwardRef) => {
|
({ className, variant, size, asChild = false, dataCY, ...props }, forwardRef) => {
|
||||||
const Comp = asChild ? Slot : 'button';
|
const Comp = asChild ? Slot : 'button';
|
||||||
const dataCY = props.dataCY || `${props.name}-btn`;
|
const testId = dataCY || `${props.name}-btn`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Comp
|
<Comp
|
||||||
data-cy={dataCY}
|
data-cy={testId}
|
||||||
className={cn(buttonVariants({ variant, size }), className)}
|
className={cn(buttonVariants({ variant, size }), className)}
|
||||||
ref={forwardRef}
|
ref={forwardRef}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { ErrorBoundary as ReactErrorBoundary, FallbackProps } from 'react-error-boundary';
|
import { ErrorBoundary as ReactErrorBoundary, FallbackProps } from 'react-error-boundary';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Dialog, DialogContent } from '../Dialog/Dialog';
|
import { Dialog, DialogContent, DialogTitle } from '../Dialog/Dialog';
|
||||||
import { ScrollArea } from '../ScrollArea/ScrollArea';
|
import { ScrollArea } from '../ScrollArea/ScrollArea';
|
||||||
import { Button } from '../Button/Button';
|
import { Button } from '../Button/Button';
|
||||||
import { useNotification } from '../../contextProviders';
|
import { useNotification } from '../../contextProviders';
|
||||||
@ -181,6 +181,7 @@ const DefaultFallback = ({
|
|||||||
open={showDetails}
|
open={showDetails}
|
||||||
onOpenChange={setShowDetails}
|
onOpenChange={setShowDetails}
|
||||||
>
|
>
|
||||||
|
<DialogTitle className="invisible">{errorTitle}</DialogTitle>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
className="bg-muted max-w-3xl overflow-hidden border-0 p-0"
|
className="bg-muted max-w-3xl overflow-hidden border-0 p-0"
|
||||||
onInteractOutside={e => e.preventDefault()}
|
onInteractOutside={e => e.preventDefault()}
|
||||||
@ -262,7 +263,6 @@ const ErrorBoundary = ({
|
|||||||
let errorTimeout: NodeJS.Timeout;
|
let errorTimeout: NodeJS.Timeout;
|
||||||
|
|
||||||
const handleError = (event: ErrorEvent) => {
|
const handleError = (event: ErrorEvent) => {
|
||||||
event.preventDefault();
|
|
||||||
clearTimeout(errorTimeout);
|
clearTimeout(errorTimeout);
|
||||||
errorTimeout = setTimeout(() => {
|
errorTimeout = setTimeout(() => {
|
||||||
setError(event.error);
|
setError(event.error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user