🔄 fix: update navigation logic in useFocusChatEffect to ensure correct search parameters are used (#7340)

This commit is contained in:
matt burnett 2025-05-13 08:24:40 -04:00 committed by GitHub
parent f2f285ca1e
commit 502617db24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 404 additions and 2 deletions

View file

@ -11,11 +11,16 @@ export default function useFocusChatEffect(textAreaRef: React.RefObject<HTMLText
'conversation',
`Focusing textarea on location state change: ${location.pathname}`,
);
/** Check if the device is not a touchscreen */
if (!window.matchMedia?.('(pointer: coarse)').matches) {
textAreaRef.current?.focus();
}
navigate(`${location.pathname}${location.search ?? ''}`, { replace: true, state: {} });
navigate(`${location.pathname}${window.location.search ?? ''}`, {
replace: true,
state: {},
});
}
}, [navigate, textAreaRef, location.pathname, location.state?.focusChat, location.search]);
}, [navigate, textAreaRef, location.pathname, location.state?.focusChat]);
}