fix: traces back button issue (#8041)

Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
This commit is contained in:
Sahil Khan 2025-06-10 18:55:59 +05:30 committed by GitHub
parent 85f04e4bae
commit 33e70d1f37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,7 +42,19 @@ function TraceMetadata(props: ITraceMetadataProps): JSX.Element {
<Button className="previous-btn">
<ArrowLeft
size={14}
onClick={(): void => history.push(ROUTES.TRACES_EXPLORER)}
onClick={(): void => {
// Check if page was opened in new tab (no referrer from same origin)
// or if there's no meaningful history to go back to
const hasValidReferrer =
document.referrer &&
new URL(document.referrer).origin === window.location.origin;
if (hasValidReferrer && window.history.length > 1) {
history.goBack();
} else {
history.push(ROUTES.TRACES_EXPLORER);
}
}}
/>
</Button>
<div className="trace-name">