@@ -44,7 +44,6 @@ import { hasInterceptionRouteInCurrentTree } from './router-reducer/reducers/has
4444import { dispatchAppRouterAction } from './use-action-queue'
4545import { useRouterBFCache , type RouterBFCacheEntry } from './bfcache'
4646import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'
47- import { PAGE_SEGMENT_KEY } from '../../shared/lib/segment'
4847import {
4948 NavigationPromisesContext ,
5049 type NavigationPromises ,
@@ -348,7 +347,7 @@ function InnerLayoutRouter({
348347} : {
349348 tree : FlightRouterState
350349 segmentPath : FlightSegmentPath
351- debugNameContext : ActivityProps [ 'name' ]
350+ debugNameContext : string
352351 cacheNode : CacheNode
353352 params : Params
354353 url : string
@@ -584,7 +583,7 @@ export default function OuterLayoutRouter({
584583 parentParams,
585584 url,
586585 isActive,
587- debugNameContext : parentDebugNameContext ,
586+ debugNameContext,
588587 } = context
589588
590589 // Get the CacheNode for this segment by reading it from the parent segment's
@@ -706,9 +705,20 @@ export default function OuterLayoutRouter({
706705
707706 const debugName = getBoundaryDebugNameFromSegment ( segment )
708707 // `debugNameContext` represents the nearest non-"virtual" parent segment.
709- // `getBoundaryDebugNameFromSegment` returns null for virtual segments.
710- // So if `debugName` is null, the context is passed through unchanged.
711- const debugNameContext = debugName ?? parentDebugNameContext
708+ // `getBoundaryDebugNameFromSegment` returns undefined for virtual segments.
709+ // So if `debugName` is undefined, the context is passed through unchanged.
710+ const childDebugNameContext = debugName ?? debugNameContext
711+
712+ // In practical terms, clicking this name in the Suspense DevTools
713+ // should select the child slots of that layout.
714+ //
715+ // So the name we apply to the Activity boundary is actually based on
716+ // the nearest parent segments.
717+ //
718+ // We skip over "virtual" parents, i.e. ones inserted by Next.js that
719+ // don't correspond to application-defined code.
720+ const isVirtual = debugName === undefined
721+ const debugNameToDisplay = isVirtual ? undefined : debugNameContext
712722
713723 // TODO: The loading module data for a segment is stored on the parent, then
714724 // applied to each of that parent segment's parallel route slots. In the
@@ -729,7 +739,10 @@ export default function OuterLayoutRouter({
729739 errorStyles = { errorStyles }
730740 errorScripts = { errorScripts }
731741 >
732- < LoadingBoundary name = { debugName } loading = { loadingModuleData } >
742+ < LoadingBoundary
743+ name = { debugNameToDisplay }
744+ loading = { loadingModuleData }
745+ >
733746 < HTTPAccessFallbackBoundary
734747 notFound = { notFound }
735748 forbidden = { forbidden }
@@ -742,7 +755,7 @@ export default function OuterLayoutRouter({
742755 params = { params }
743756 cacheNode = { cacheNode }
744757 segmentPath = { segmentPath }
745- debugNameContext = { debugNameContext }
758+ debugNameContext = { childDebugNameContext }
746759 isActive = { isActive && stateKey === activeStateKey }
747760 />
748761 { segmentBoundaryTriggerNode }
@@ -775,15 +788,7 @@ export default function OuterLayoutRouter({
775788 if ( process . env . __NEXT_CACHE_COMPONENTS ) {
776789 child = (
777790 < Activity
778- // In practical terms, clicking this name in the Suspense DevTools
779- // should select the child slots of that layout.
780- //
781- // So the name we apply to the Activity boundary is actually based on
782- // the nearest parent segments.
783- //
784- // We skip over "virtual" parents, i.e. ones inserted by Next.js that
785- // don't correspond to application-defined code.
786- name = { debugNameContext }
791+ name = { debugNameToDisplay }
787792 key = { stateKey }
788793 mode = { stateKey === activeStateKey ? 'visible' : 'hidden' }
789794 >
@@ -821,12 +826,6 @@ function isVirtualLayout(segment: string): boolean {
821826 // This is inserted by the loader. We should consider encoding these
822827 // in a more special way instead of checking the name, to distinguish them
823828 // from app-defined groups.
824- segment === '(slot)' ||
825- // For some reason, the loader tree sometimes includes extra __PAGE__
826- // "layouts" when part of a parallel route. But it's not a leaf node.
827- // Otherwise, we wouldn't need this special case because pages are
828- // always leaf nodes.
829- // TODO: Investigate why the loader produces these fake page segments.
830- segment . startsWith ( PAGE_SEGMENT_KEY )
829+ segment === '(slot)'
831830 )
832831}
0 commit comments