33// SPDX-License-Identifier: AGPL-3.0-only
44// Please see LICENSE in the repository root for full details.
55
6+ import { queryOptions , useSuspenseQuery } from "@tanstack/react-query" ;
67import { createFileRoute } from "@tanstack/react-router" ;
8+ import { useCallback , useEffect , useRef , useState } from "react" ;
79import { graphql , useFragment } from "../gql" ;
810import { graphqlRequest } from "../graphql" ;
9- import { queryOptions , useSuspenseQuery } from "@tanstack/react-query" ;
10- import { useEffect , useRef , useState } from "react" ;
1111
1212export const CONFIG_FRAGMENT = graphql ( /* GraphQL */ `
1313 fragment PlanManagement_siteConfig on SiteConfig {
@@ -43,18 +43,19 @@ function Plan(): React.ReactElement {
4343 }
4444
4545 const ref = useRef < HTMLIFrameElement > ( null ) ;
46- const [ height , setHeight ] = useState ( ' 0px' ) ;
46+ const [ height , setHeight ] = useState ( " 0px" ) ;
4747
4848 // Poll the size of the iframe content and set the height
4949 // This will only work where the iframe is served from the same origin
50- const doHeight = ( ) => {
51- const height = ref . current ?. contentWindow ?. document . body . parentElement ?. scrollHeight ;
50+ const doHeight = useCallback ( ( ) => {
51+ const height =
52+ ref . current ?. contentWindow ?. document . body . parentElement ?. scrollHeight ;
5253 if ( height ) {
53- setHeight ( height + 'px' ) ;
54+ setHeight ( ` ${ height } px` ) ;
5455 } else {
55- setHeight ( ' 500px' ) ;
56+ setHeight ( " 500px" ) ;
5657 }
57- } ;
58+ } , [ ] ) ;
5859 useEffect ( ( ) => {
5960 doHeight ( ) ;
6061
@@ -63,10 +64,11 @@ function Plan(): React.ReactElement {
6364 } , 1000 ) ;
6465
6566 return ( ) => clearInterval ( interval ) ;
66- } , [ ] ) ;
67+ } , [ doHeight ] ) ;
6768
6869 return (
6970 < iframe
71+ title = "asd"
7072 ref = { ref }
7173 onLoad = { doHeight }
7274 src = { planManagementIframeUri }
0 commit comments