@@ -17,9 +17,20 @@ export default function SideNavigationTemplate(this: SideNavigation) {
1717 target = { item . target }
1818 title = { item . title }
1919 tooltip = { item . _tooltip }
20- ref = { this . captureRef . bind ( item ) }
20+ ref = { ( el : HTMLElement | null ) => {
21+ if ( el && item . tag . length > 0 ) {
22+ if ( ! el . hasAttribute ( 'data-tags-appended' ) ) {
23+ item . tag . forEach ( ( tagEl ) => {
24+ const clonedTag = tagEl . cloneNode ( true ) as HTMLElement ;
25+ clonedTag . slot = 'endContent' ;
26+ el . appendChild ( clonedTag ) ;
27+ } ) ;
28+ el . setAttribute ( 'data-tags-appended' , 'true' ) ;
29+ }
30+ }
31+ this . captureRef . bind ( item ) ( el as any ) ;
32+ } }
2133 >
22-
2334 { item . children . length > 0 && ! item . unselectable &&
2435 ( < NavigationMenuItem
2536 class = "ui5-navigation-menu-item-root-parent"
@@ -31,8 +42,21 @@ export default function SideNavigationTemplate(this: SideNavigation) {
3142 target = { item . target }
3243 title = { item . title }
3344 tooltip = { item . _tooltip }
34- ref = { this . captureRef . bind ( item ) }
35- > </ NavigationMenuItem > )
45+ ref = { ( el : HTMLElement | null ) => {
46+ if ( el && item . tag . length > 0 ) {
47+ if ( ! el . hasAttribute ( 'data-tags-appended' ) ) {
48+ item . tag . forEach ( ( tagEl ) => {
49+ const clonedTag = tagEl . cloneNode ( true ) as HTMLElement ;
50+ clonedTag . slot = 'endContent' ;
51+ el . appendChild ( clonedTag ) ;
52+ } ) ;
53+ el . setAttribute ( 'data-tags-appended' , 'true' ) ;
54+ }
55+ }
56+ this . captureRef . bind ( item ) ( el as any ) ;
57+ } }
58+ >
59+ </ NavigationMenuItem > )
3660 }
3761
3862 { ( item as any ) . items ?. map ( renderMenuItem ) }
@@ -79,7 +103,20 @@ export default function SideNavigationTemplate(this: SideNavigation) {
79103 selected = { this . _popoverContents . item . selected }
80104 unselectable = { this . _popoverContents . item . unselectable }
81105 onui5-click = { this . handlePopupItemClick }
82- ref = { this . captureRef . bind ( this . _popoverContents . item ) }
106+ ref = { ( el : HTMLElement | null ) => {
107+ if ( el && this . _popoverContents . item . tag . length > 0 ) {
108+ // Only append if the element doesn't have our marker
109+ if ( ! el . hasAttribute ( 'data-tags-appended' ) ) {
110+ this . _popoverContents . item . tag . forEach ( ( tagEl ) => {
111+ const clonedTag = tagEl . cloneNode ( true ) as HTMLElement ;
112+ clonedTag . slot = 'tag' ;
113+ el . appendChild ( clonedTag ) ;
114+ } ) ;
115+ el . setAttribute ( 'data-tags-appended' , 'true' ) ;
116+ }
117+ }
118+ this . captureRef . bind ( this . _popoverContents . item ) ( el as SideNavigationItem | null ) ;
119+ } }
83120 >
84121 { this . _popoverContents . subItems . map ( item =>
85122 < SideNavigationSubItem
@@ -93,8 +130,22 @@ export default function SideNavigationTemplate(this: SideNavigation) {
93130 selected = { item . selected }
94131 unselectable = { item . unselectable }
95132 onui5-click = { this . handlePopupItemClick }
96- ref = { this . captureRef . bind ( item ) }
97- />
133+ ref = { ( el : HTMLElement | null ) => {
134+ if ( el && item . tag . length > 0 ) {
135+ // Only append if the element doesn't have our marker
136+ if ( ! el . hasAttribute ( 'data-tags-appended' ) ) {
137+ item . tag . forEach ( ( tagEl ) => {
138+ const clonedTag = tagEl . cloneNode ( true ) as HTMLElement ;
139+ clonedTag . slot = 'tag' ;
140+ el . appendChild ( clonedTag ) ;
141+ } ) ;
142+ el . setAttribute ( 'data-tags-appended' , 'true' ) ;
143+ }
144+ }
145+ this . captureRef . bind ( item ) ( el as SideNavigationSubItem | null ) ;
146+ } }
147+ >
148+ </ SideNavigationSubItem >
98149 ) }
99150 </ SideNavigationItem >
100151 </ SideNavigation >
0 commit comments