Skip to content

Commit

Permalink
debug resizeobserver error
Browse files Browse the repository at this point in the history
  • Loading branch information
aeltorio committed Nov 6, 2024
1 parent f544cd9 commit 1cc94a4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/aipane/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -32,6 +33,20 @@ const Header: React.FC<HeaderProps> = (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 (
<section className={styles.welcome__header}>
<Image width="90" height="90" src={logo} alt={title} />
Expand Down
16 changes: 16 additions & 0 deletions src/aipane/components/HeroApiKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,6 +33,21 @@ const useStyles = makeStyles({
const HeroApiKey: React.FC<HeroApiKeyProps> = ({ 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 (
<div className={styles.root}>
<Label htmlFor={inputId} size="large">
Expand Down
14 changes: 14 additions & 0 deletions src/aipane/components/HeroModels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ const HeroModels: React.FC<HeroModelsProps> = ({ onChange, provider }) => {
onChange(selectedValue);
}, [selectedValue, onChange]);

useEffect(() => {
const resizeObserverErr = (e: ErrorEvent) => {
if (e.message === "ResizeObserver loop completed with undelivered notifications.") {
console.error("ResizeObserver loop error in HeroModels");
e.stopImmediatePropagation();
e.stopPropagation();
}
};
window.addEventListener("error", resizeObserverErr);
return () => {
window.removeEventListener("error", resizeObserverErr);
};
}, []);

return (
<div className={styles.root}>
<Label htmlFor={selectId} size="large">
Expand Down
14 changes: 14 additions & 0 deletions src/aipane/components/HeroProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ const HeroProviders: React.FC<HeroProvidersProps> = ({ onChange }) => {
setProviders(config.providers);
}, []);

useEffect(() => {
const resizeObserverErr = (e: ErrorEvent) => {
if (e.message === "ResizeObserver loop completed with undelivered notifications.") {
console.error("ResizeObserver loop error in HeroProviders");
e.stopImmediatePropagation();
e.stopPropagation();
}
};
window.addEventListener("error", resizeObserverErr);
return () => {
window.removeEventListener("error", resizeObserverErr);
};
}, []);

const handleChange = React.useCallback(
(event: React.FormEvent<HTMLButtonElement>, option?: any) => {
event.preventDefault();
Expand Down
14 changes: 14 additions & 0 deletions src/aipane/components/TextInsertion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ const TextInsertion: React.FC<TextInsertionProps> = (props: TextInsertionProps):
});
}, []);

useEffect(() => {
const resizeObserverErr = (e: ErrorEvent) => {
if (e.message === "ResizeObserver loop completed with undelivered notifications.") {
console.error("ResizeObserver loop error in TextInsertion");
e.stopImmediatePropagation();
e.stopPropagation();
}
};
window.addEventListener("error", resizeObserverErr);
return () => {
window.removeEventListener("error", resizeObserverErr);
};
}, []);

return (
<div className={styles.textPromptAndInsertion}>
<Field className={styles.textAreaField} size="large" label="Enter your message.">
Expand Down

0 comments on commit 1cc94a4

Please sign in to comment.