11import { MdOutlineFeedback } from 'react-icons/md' ;
22
3- import { useEffect , useMemo , useState , type JSX } from 'react' ;
3+ import { useMemo , type JSX } from 'react' ;
44
55import { useLocation } from '@tanstack/react-router' ;
66
@@ -25,27 +25,27 @@ const SendFeedback = (
2525) : JSX . Element => {
2626 const location = useLocation ( ) ;
2727
28- const [ fullLocation , setFullLocation ] = useState (
29- ` ${ window . location . origin } ${ location . pathname } ${ location . search } ${ location . hash } ` ,
30- ) ;
31-
32- useEffect ( ( ) => {
33- const newUrl = ` ${ window . location . origin } ${ location . pathname } ${ location . search } ${ location . hash } ` ;
34- setFullLocation ( newUrl ) ;
28+ const fullLocation = useMemo ( ( ) => {
29+ const href = location . href ;
30+ // href is relative (starts with "/"), prepend origin
31+ if ( href . startsWith ( '/' ) ) {
32+ return ` ${ window . location . origin } ${ href } ` ;
33+ }
34+ return href ;
3535 } , [ location ] ) ;
3636
3737 const actionLinks : ActionLink [ ] = useMemo ( ( ) => {
3838 const github_body = encodeURIComponent (
3939 `# Feedback Description:
40-
40+
4141## URL used to send feedback:
4242${ fullLocation } `,
4343 ) ;
4444
45- const email_subject = 'Dashboard Feedback' ;
45+ const email_subject = encodeURIComponent ( 'Dashboard Feedback' ) ;
4646 const email_body = encodeURIComponent (
4747 `Feedback Description:
48-
48+
4949URL used to send feedback:
5050${ fullLocation } `,
5151 ) ;
0 commit comments