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>(
|
||||
({ className, variant, size, asChild = false, ...props }, forwardRef) => {
|
||||
({ className, variant, size, asChild = false, dataCY, ...props }, forwardRef) => {
|
||||
const Comp = asChild ? Slot : 'button';
|
||||
const dataCY = props.dataCY || `${props.name}-btn`;
|
||||
const testId = dataCY || `${props.name}-btn`;
|
||||
|
||||
return (
|
||||
<Comp
|
||||
data-cy={dataCY}
|
||||
data-cy={testId}
|
||||
className={cn(buttonVariants({ variant, size }), className)}
|
||||
ref={forwardRef}
|
||||
{...props}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { ErrorBoundary as ReactErrorBoundary, FallbackProps } from 'react-error-boundary';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Dialog, DialogContent } from '../Dialog/Dialog';
|
||||
import { Dialog, DialogContent, DialogTitle } from '../Dialog/Dialog';
|
||||
import { ScrollArea } from '../ScrollArea/ScrollArea';
|
||||
import { Button } from '../Button/Button';
|
||||
import { useNotification } from '../../contextProviders';
|
||||
@ -181,6 +181,7 @@ const DefaultFallback = ({
|
||||
open={showDetails}
|
||||
onOpenChange={setShowDetails}
|
||||
>
|
||||
<DialogTitle className="invisible">{errorTitle}</DialogTitle>
|
||||
<DialogContent
|
||||
className="bg-muted max-w-3xl overflow-hidden border-0 p-0"
|
||||
onInteractOutside={e => e.preventDefault()}
|
||||
@ -262,7 +263,6 @@ const ErrorBoundary = ({
|
||||
let errorTimeout: NodeJS.Timeout;
|
||||
|
||||
const handleError = (event: ErrorEvent) => {
|
||||
event.preventDefault();
|
||||
clearTimeout(errorTimeout);
|
||||
errorTimeout = setTimeout(() => {
|
||||
setError(event.error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user