@@ -15,6 +15,7 @@ import {
1515 toast ,
1616} from "@unkey/ui" ;
1717import { parseAsBoolean , useQueryState } from "nuqs" ;
18+ import { useEffect , useRef , useState } from "react" ;
1819import { Controller , useForm } from "react-hook-form" ;
1920import { z } from "zod" ;
2021
@@ -35,6 +36,21 @@ type FormValues = z.infer<typeof feedbackSchema>;
3536
3637export const Feedback : React . FC = ( ) => {
3738 const [ open , setOpen ] = useFeedback ( ) ;
39+ const [ internalOpen , setInternalOpen ] = useState ( false ) ;
40+ const justOpenedRef = useRef ( false ) ;
41+
42+ // Sync internal state with URL query state
43+ useEffect ( ( ) => {
44+ if ( open ) {
45+ setInternalOpen ( true ) ;
46+ justOpenedRef . current = true ;
47+ const timer = setTimeout ( ( ) => {
48+ justOpenedRef . current = false ;
49+ } , 500 ) ;
50+ return ( ) => clearTimeout ( timer ) ;
51+ }
52+ setInternalOpen ( false ) ;
53+ } , [ open ] ) ;
3854
3955 const {
4056 handleSubmit,
@@ -68,10 +84,23 @@ export const Feedback: React.FC = () => {
6884 }
6985 } ;
7086
87+ const handleClose = ( ) => {
88+ if ( justOpenedRef . current ) {
89+ return ; // Prevent closing if just opened
90+ }
91+ setOpen ( false ) ;
92+ } ;
93+
7194 return (
7295 < DialogContainer
73- isOpen = { Boolean ( open ) }
74- onOpenChange = { setOpen }
96+ isOpen = { internalOpen }
97+ onOpenChange = { ( newOpen ) => {
98+ if ( ! newOpen ) {
99+ handleClose ( ) ;
100+ }
101+ } }
102+ showCloseWarning = { false }
103+ onAttemptClose = { handleClose }
75104 title = "Report an issue"
76105 subTitle = "What went wrong or how can we improve?"
77106 footer = {
0 commit comments