@@ -340,12 +340,10 @@ interface TagTreeNode {
340340const buildNestedTagTree = ( tags : string [ ] , blockName : string ) : NestedTag [ ] => {
341341 const root : TagTreeNode = { key : 'root' , children : new Map ( ) }
342342
343- // Build tree from tags
344343 for ( const tag of tags ) {
345344 const parts = tag . split ( '.' )
346- if ( parts . length < 2 ) continue // Skip root-only tags
345+ if ( parts . length < 2 ) continue
347346
348- // Skip the blockname part, start from the first property
349347 const pathParts = parts . slice ( 1 )
350348 let current = root
351349
@@ -359,15 +357,13 @@ const buildNestedTagTree = (tags: string[], blockName: string): NestedTag[] => {
359357 }
360358 const node = current . children . get ( part ) !
361359
362- // If this is the last part, store the full tag
363360 if ( i === pathParts . length - 1 ) {
364361 node . fullTag = tag
365362 }
366363 current = node
367364 }
368365 }
369366
370- // Convert tree to NestedTag array
371367 const convertToNestedTags = (
372368 node : TagTreeNode ,
373369 parentPath : string ,
@@ -380,17 +376,14 @@ const buildNestedTagTree = (tags: string[], blockName: string): NestedTag[] => {
380376 const parentTag = `${ blockPrefix } .${ currentPath } `
381377
382378 if ( child . children . size === 0 ) {
383- // Leaf node
384379 result . push ( {
385380 key : currentPath ,
386381 display : key ,
387382 fullTag : child . fullTag || parentTag ,
388383 } )
389384 } else {
390- // Folder node - may have both leaf value and children
391385 const nestedChildren = convertToNestedTags ( child , currentPath , blockPrefix )
392386
393- // Separate leaf children from nested folders
394387 const leafChildren : NestedTagChild [ ] = [ ]
395388 const folders : NestedTag [ ] = [ ]
396389
@@ -483,10 +476,8 @@ const FolderContentsInner: React.FC<FolderContentsProps> = ({
483476 nestedTag,
484477 onNavigateIn,
485478} ) => {
486- // Get the current folder based on nested path
487479 const currentNestedTag = nestedPath . length > 0 ? nestedPath [ nestedPath . length - 1 ] : nestedTag
488480
489- // Find parent tag index for highlighting
490481 const parentTagIndex = currentNestedTag . parentTag
491482 ? flatTagList . findIndex ( ( item ) => item . tag === currentNestedTag . parentTag )
492483 : - 1
@@ -609,7 +600,6 @@ const FolderContents: React.FC<NestedTagRendererProps> = (props) => {
609600
610601 const nestedPath = nestedNav ?. nestedPath ?? [ ]
611602
612- // Register this folder when it becomes active
613603 useEffect ( ( ) => {
614604 if ( nestedNav && currentFolder ) {
615605 const folderId = `${ props . group . blockId } -${ props . nestedTag . key } `
@@ -647,7 +637,6 @@ const NestedTagRenderer: React.FC<NestedTagRendererProps> = ({
647637 const hasChildren = nestedTag . children && nestedTag . children . length > 0
648638 const hasNestedChildren = nestedTag . nestedChildren && nestedTag . nestedChildren . length > 0
649639
650- // If this tag has children (leaf or nested), render as a folder
651640 if ( hasChildren || hasNestedChildren ) {
652641 const folderId = `${ group . blockId } -${ nestedTag . key } `
653642
@@ -863,7 +852,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
863852 const [ selectedIndex , setSelectedIndex ] = useState ( 0 )
864853 const itemRefs = useRef < Map < number , HTMLElement > > ( new Map ( ) )
865854
866- // Nested navigation state - supports unlimited nesting depth
867855 const [ nestedPath , setNestedPath ] = useState < NestedTag [ ] > ( [ ] )
868856 const baseFolderRef = useRef < {
869857 id : string
@@ -1578,31 +1566,25 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
15781566 list . push ( { tag } )
15791567 } )
15801568
1581- // Recursively flatten nested tags
15821569 const flattenNestedTag = ( nestedTag : NestedTag , group : BlockTagGroup , rootTag : string ) => {
1583- // Skip if this is the root tag (already added)
15841570 if ( nestedTag . fullTag === rootTag ) {
15851571 return
15861572 }
15871573
1588- // Add parent tag for folders
15891574 if ( nestedTag . parentTag ) {
15901575 list . push ( { tag : nestedTag . parentTag , group } )
15911576 }
15921577
1593- // Add the tag itself if it's a leaf
15941578 if ( nestedTag . fullTag && ! nestedTag . children && ! nestedTag . nestedChildren ) {
15951579 list . push ( { tag : nestedTag . fullTag , group } )
15961580 }
15971581
1598- // Add leaf children
15991582 if ( nestedTag . children ) {
16001583 nestedTag . children . forEach ( ( child ) => {
16011584 list . push ( { tag : child . fullTag , group } )
16021585 } )
16031586 }
16041587
1605- // Recursively process nested children
16061588 if ( nestedTag . nestedChildren ) {
16071589 nestedTag . nestedChildren . forEach ( ( nestedChild ) => {
16081590 flattenNestedTag ( nestedChild , group , rootTag )
@@ -1727,15 +1709,12 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
17271709 [ inputValue , cursorPosition , workflowVariables , onSelect , onClose , getMergedSubBlocks ]
17281710 )
17291711
1730- // Keep ref updated for nested navigation
17311712 handleTagSelectRef . current = handleTagSelect
17321713
1733- // Get popover context for nested navigation (will be available inside Popover)
17341714 const popoverContextRef = useRef < {
17351715 openFolder : ( id : string , title : string , onLoad ?: ( ) => void , onSelect ?: ( ) => void ) => void
17361716 } | null > ( null )
17371717
1738- // Create nested navigation context value
17391718 const nestedNavigationValue = useMemo < NestedNavigationContextValue > (
17401719 ( ) => ( {
17411720 nestedPath,
@@ -1745,12 +1724,10 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
17451724
17461725 setNestedPath ( ( prev ) => [ ...prev , tag ] )
17471726
1748- // Reset scroll to top when navigating into a folder
17491727 if ( scrollAreaRef . current ) {
17501728 scrollAreaRef . current . scrollTop = 0
17511729 }
17521730
1753- // Update popover's folder title to show current nested folder
17541731 const selectionCallback = ( ) => {
17551732 if ( tag . parentTag && handleTagSelectRef . current ) {
17561733 handleTagSelectRef . current ( tag . parentTag , group )
@@ -1772,7 +1749,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
17721749 setNestedPath ( newPath )
17731750
17741751 if ( newPath . length === 0 ) {
1775- // Going back to root folder level
17761752 const selectionCallback = ( ) => {
17771753 if ( baseFolder . baseTag . parentTag && handleTagSelectRef . current ) {
17781754 handleTagSelectRef . current ( baseFolder . baseTag . parentTag , baseFolder . group )
@@ -1785,7 +1761,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
17851761 selectionCallback
17861762 )
17871763 } else {
1788- // Going back to a nested folder
17891764 const parentTag = newPath [ newPath . length - 1 ]
17901765 const selectionCallback = ( ) => {
17911766 if ( parentTag . parentTag && handleTagSelectRef . current ) {
@@ -1803,7 +1778,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
18031778 } ,
18041779 registerFolder : ( folderId , folderTitle , baseTag , group ) => {
18051780 baseFolderRef . current = { id : folderId , title : folderTitle , baseTag, group }
1806- // Reset scroll to top when entering a folder
18071781 if ( scrollAreaRef . current ) {
18081782 scrollAreaRef . current . scrollTop = 0
18091783 }
@@ -1812,7 +1786,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
18121786 [ nestedPath ]
18131787 )
18141788
1815- // Reset nested path when popover closes
18161789 useEffect ( ( ) => {
18171790 if ( ! visible ) {
18181791 setNestedPath ( [ ] )
0 commit comments