Merge pull request #27303 from overleaf/dp-go-to-code

Hide go to code button in the new editor logs when it does nothing

GitOrigin-RevId: f08c3fc98bae8116a428a7528291edccd6d4f8c0
This commit is contained in:
Alexandre Bourdin
2025-07-29 10:10:03 +02:00
committed by Copybot
parent 858c05a292
commit c90233c01f

View File

@@ -11,6 +11,8 @@ import useResizeObserver from '@/features/preview/hooks/use-resize-observer'
import OLIconButton from '@/features/ui/components/ol/ol-icon-button'
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
import MaterialIcon from '@/shared/components/material-icon'
import { useFileTreePathContext } from '@/features/file-tree/contexts/file-tree-path'
import { useFileTreeOpenContext } from '@/features/ide-react/context/file-tree-open-context'
const actionComponents = importOverleafModules(
'pdfLogEntryHeaderActionComponents'
@@ -49,6 +51,8 @@ function LogEntryHeader({
const { t } = useTranslation()
const logLocationSpanRef = useRef<HTMLSpanElement>(null)
const [locationSpanOverflown, setLocationSpanOverflown] = useState(false)
const { findEntityByPath } = useFileTreePathContext()
const { openEntity } = useFileTreeOpenContext()
useResizeObserver(
logLocationSpanRef,
@@ -95,6 +99,11 @@ function LogEntryHeader({
) : null
const headerTitleText = logType ? `${logType} ${headerTitle}` : headerTitle
const fileData = file && findEntityByPath(file)
const showGoToCodeButton =
showSourceLocationLink &&
!!fileData &&
!(fileData.entity._id === openEntity?.entity._id && !line)
return (
<header className="log-entry-header-card">
@@ -136,7 +145,7 @@ function LogEntryHeader({
{actionButtonsOverride ?? (
<div className="log-entry-header-actions">
{showSourceLocationLink && (
{showGoToCodeButton && (
<OLTooltip
id={`go-to-location-${locationText}`}
description={t('go_to_code_location')}