@@ -1312,44 +1312,48 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
13121312 if ( currentLoop && isLoopBlock ) {
13131313 containingLoopBlockId = blockId
13141314 const loopType = currentLoop . loopType || 'for'
1315- const contextualTags : string [ ] = [ 'index' ]
1316- if ( loopType === 'forEach' ) {
1317- contextualTags . push ( 'currentItem' )
1318- contextualTags . push ( 'items' )
1319- }
13201315
13211316 const loopBlock = blocks [ blockId ]
13221317 if ( loopBlock ) {
13231318 const loopBlockName = loopBlock . name || loopBlock . type
1319+ const normalizedLoopName = normalizeName ( loopBlockName )
1320+ const contextualTags : string [ ] = [ `${ normalizedLoopName } .index` ]
1321+ if ( loopType === 'forEach' ) {
1322+ contextualTags . push ( `${ normalizedLoopName } .currentItem` )
1323+ contextualTags . push ( `${ normalizedLoopName } .items` )
1324+ }
13241325
13251326 loopBlockGroup = {
13261327 blockName : loopBlockName ,
13271328 blockId : blockId ,
13281329 blockType : 'loop' ,
13291330 tags : contextualTags ,
13301331 distance : 0 ,
1332+ isContextual : true ,
13311333 }
13321334 }
13331335 } else if ( containingLoop ) {
13341336 const [ loopId , loop ] = containingLoop
13351337 containingLoopBlockId = loopId
13361338 const loopType = loop . loopType || 'for'
1337- const contextualTags : string [ ] = [ 'index' ]
1338- if ( loopType === 'forEach' ) {
1339- contextualTags . push ( 'currentItem' )
1340- contextualTags . push ( 'items' )
1341- }
13421339
13431340 const containingLoopBlock = blocks [ loopId ]
13441341 if ( containingLoopBlock ) {
13451342 const loopBlockName = containingLoopBlock . name || containingLoopBlock . type
1343+ const normalizedLoopName = normalizeName ( loopBlockName )
1344+ const contextualTags : string [ ] = [ `${ normalizedLoopName } .index` ]
1345+ if ( loopType === 'forEach' ) {
1346+ contextualTags . push ( `${ normalizedLoopName } .currentItem` )
1347+ contextualTags . push ( `${ normalizedLoopName } .items` )
1348+ }
13461349
13471350 loopBlockGroup = {
13481351 blockName : loopBlockName ,
13491352 blockId : loopId ,
13501353 blockType : 'loop' ,
13511354 tags : contextualTags ,
13521355 distance : 0 ,
1356+ isContextual : true ,
13531357 }
13541358 }
13551359 }
@@ -1363,22 +1367,24 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
13631367 const [ parallelId , parallel ] = containingParallel
13641368 containingParallelBlockId = parallelId
13651369 const parallelType = parallel . parallelType || 'count'
1366- const contextualTags : string [ ] = [ 'index' ]
1367- if ( parallelType === 'collection' ) {
1368- contextualTags . push ( 'currentItem' )
1369- contextualTags . push ( 'items' )
1370- }
13711370
13721371 const containingParallelBlock = blocks [ parallelId ]
13731372 if ( containingParallelBlock ) {
13741373 const parallelBlockName = containingParallelBlock . name || containingParallelBlock . type
1374+ const normalizedParallelName = normalizeName ( parallelBlockName )
1375+ const contextualTags : string [ ] = [ `${ normalizedParallelName } .index` ]
1376+ if ( parallelType === 'collection' ) {
1377+ contextualTags . push ( `${ normalizedParallelName } .currentItem` )
1378+ contextualTags . push ( `${ normalizedParallelName } .items` )
1379+ }
13751380
13761381 parallelBlockGroup = {
13771382 blockName : parallelBlockName ,
13781383 blockId : parallelId ,
13791384 blockType : 'parallel' ,
13801385 tags : contextualTags ,
13811386 distance : 0 ,
1387+ isContextual : true ,
13821388 }
13831389 }
13841390 }
@@ -1645,38 +1651,29 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
16451651 const nestedBlockTagGroups : NestedBlockTagGroup [ ] = useMemo ( ( ) => {
16461652 return filteredBlockTagGroups . map ( ( group : BlockTagGroup ) => {
16471653 const normalizedBlockName = normalizeName ( group . blockName )
1648-
1649- // Handle loop/parallel contextual tags (index, currentItem, items)
16501654 const directTags : NestedTag [ ] = [ ]
16511655 const tagsForTree : string [ ] = [ ]
16521656
16531657 group . tags . forEach ( ( tag : string ) => {
16541658 const tagParts = tag . split ( '.' )
16551659
1656- // Loop/parallel contextual tags without block prefix
1657- if (
1658- ( group . blockType === 'loop' || group . blockType === 'parallel' ) &&
1659- tagParts . length === 1
1660- ) {
1660+ if ( tagParts . length === 1 ) {
16611661 directTags . push ( {
16621662 key : tag ,
16631663 display : tag ,
16641664 fullTag : tag ,
16651665 } )
16661666 } else if ( tagParts . length === 2 ) {
1667- // Direct property like blockname.property
16681667 directTags . push ( {
16691668 key : tagParts [ 1 ] ,
16701669 display : tagParts [ 1 ] ,
16711670 fullTag : tag ,
16721671 } )
16731672 } else {
1674- // Nested property - add to tree builder
16751673 tagsForTree . push ( tag )
16761674 }
16771675 } )
16781676
1679- // Build recursive tree from nested tags
16801677 const nestedTags = [ ...directTags , ...buildNestedTagTree ( tagsForTree , normalizedBlockName ) ]
16811678
16821679 return {
@@ -1800,13 +1797,19 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
18001797 processedTag = tag
18011798 }
18021799 } else if (
1803- blockGroup &&
1800+ blockGroup ?. isContextual &&
18041801 ( blockGroup . blockType === 'loop' || blockGroup . blockType === 'parallel' )
18051802 ) {
1806- if ( ! tag . includes ( '.' ) && [ 'index' , 'currentItem' , 'items' ] . includes ( tag ) ) {
1807- processedTag = `${ blockGroup . blockType } .${ tag } `
1803+ const tagParts = tag . split ( '.' )
1804+ if ( tagParts . length === 1 ) {
1805+ processedTag = blockGroup . blockType
18081806 } else {
1809- processedTag = tag
1807+ const lastPart = tagParts [ tagParts . length - 1 ]
1808+ if ( [ 'index' , 'currentItem' , 'items' ] . includes ( lastPart ) ) {
1809+ processedTag = `${ blockGroup . blockType } .${ lastPart } `
1810+ } else {
1811+ processedTag = tag
1812+ }
18101813 }
18111814 }
18121815
0 commit comments