From 1cc94a4e3be06d0129719b954b1b6a0092671aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A6Ltorio?= Date: Wed, 6 Nov 2024 16:39:24 +0100 Subject: [PATCH] debug resizeobserver error --- src/aipane/components/Header.tsx | 15 +++++++++++++++ src/aipane/components/HeroApiKey.tsx | 16 ++++++++++++++++ src/aipane/components/HeroModels.tsx | 14 ++++++++++++++ src/aipane/components/HeroProviders.tsx | 14 ++++++++++++++ src/aipane/components/TextInsertion.tsx | 14 ++++++++++++++ 5 files changed, 73 insertions(+) diff --git a/src/aipane/components/Header.tsx b/src/aipane/components/Header.tsx index 1121523..5e40c39 100644 --- a/src/aipane/components/Header.tsx +++ b/src/aipane/components/Header.tsx @@ -5,6 +5,7 @@ */ import * as React from "react"; import { Image, tokens, makeStyles } from "@fluentui/react-components"; +import { useEffect } from "react"; export interface HeaderProps { title: string; @@ -32,6 +33,20 @@ const Header: React.FC = (props: HeaderProps) => { const { title, logo, message } = props; const styles = useStyles(); + useEffect(() => { + const resizeObserverErr = (e: ErrorEvent) => { + if (e.message === "ResizeObserver loop completed with undelivered notifications.") { + console.error("ResizeObserver loop error in Header"); + e.stopImmediatePropagation(); + e.stopPropagation(); + } + }; + window.addEventListener("error", resizeObserverErr); + return () => { + window.removeEventListener("error", resizeObserverErr); + }; + }, []); + return (
{title} diff --git a/src/aipane/components/HeroApiKey.tsx b/src/aipane/components/HeroApiKey.tsx index 23cf55a..0f2282d 100644 --- a/src/aipane/components/HeroApiKey.tsx +++ b/src/aipane/components/HeroApiKey.tsx @@ -6,6 +6,7 @@ import * as React from "react"; import { makeStyles, useId, Button, Input, Label } from "@fluentui/react-components"; import { AIProvider } from "../AIPrompt"; +import { useEffect } from "react"; interface HeroApiKeyProps { provider: AIProvider; @@ -32,6 +33,21 @@ const useStyles = makeStyles({ const HeroApiKey: React.FC = ({ apiKey, onApiKeyChange, onApiKeySubmit, provider }) => { const styles = useStyles(); const inputId = useId("input"); + + useEffect(() => { + const resizeObserverErr = (e: ErrorEvent) => { + if (e.message === "ResizeObserver loop completed with undelivered notifications.") { + console.error("ResizeObserver loop error in HeroApiKey"); + e.stopImmediatePropagation(); + e.stopPropagation(); + } + }; + window.addEventListener("error", resizeObserverErr); + return () => { + window.removeEventListener("error", resizeObserverErr); + }; + }, []); + return (