@@ -260,4 +260,65 @@ describe("General API", () => {
260260 cy . get ( "@signInDialog" )
261261 . should ( "be.visible" ) ;
262262 } ) ;
263+
264+ it ( "tabindex should update when text content is added after mount" , ( ) => {
265+ // Mount link without text content
266+ cy . mount ( < Link id = "dynamic-link" > </ Link > ) ;
267+
268+ // Initially, tabindex should be -1 because there's no text content
269+ cy . get ( "#dynamic-link" )
270+ . shadow ( )
271+ . find ( ".ui5-link-root" )
272+ . should ( "have.attr" , "tabindex" , "-1" ) ;
273+
274+ // Add text content dynamically
275+ cy . get ( "#dynamic-link" )
276+ . then ( $link => {
277+ $link [ 0 ] . textContent = "Click me" ;
278+ } ) ;
279+
280+ // After text is added, tabindex should become 0
281+ cy . get ( "#dynamic-link" )
282+ . shadow ( )
283+ . find ( ".ui5-link-root" )
284+ . should ( "have.attr" , "tabindex" , "0" ) ;
285+ } ) ;
286+
287+ it ( "tabindex should remain 0 when text content changes" , ( ) => {
288+ cy . mount ( < Link id = "text-change-link" > Initial Text</ Link > ) ;
289+
290+ cy . get ( "#text-change-link" )
291+ . shadow ( )
292+ . find ( ".ui5-link-root" )
293+ . should ( "have.attr" , "tabindex" , "0" ) ;
294+
295+ cy . get ( "#text-change-link" )
296+ . then ( $link => {
297+ $link [ 0 ] . textContent = "Updated Text" ;
298+ } ) ;
299+
300+ cy . get ( "#text-change-link" )
301+ . shadow ( )
302+ . find ( ".ui5-link-root" )
303+ . should ( "have.attr" , "tabindex" , "0" ) ;
304+ } ) ;
305+
306+ it ( "tabindex should be -1 when text content is removed" , ( ) => {
307+ cy . mount ( < Link id = "remove-text-link" > Some text</ Link > ) ;
308+
309+ cy . get ( "#remove-text-link" )
310+ . shadow ( )
311+ . find ( ".ui5-link-root" )
312+ . should ( "have.attr" , "tabindex" , "0" ) ;
313+
314+ cy . get ( "#remove-text-link" )
315+ . then ( $link => {
316+ $link [ 0 ] . textContent = "" ;
317+ } ) ;
318+
319+ cy . get ( "#remove-text-link" )
320+ . shadow ( )
321+ . find ( ".ui5-link-root" )
322+ . should ( "have.attr" , "tabindex" , "-1" ) ;
323+ } ) ;
263324} ) ;
0 commit comments