@@ -346,6 +346,64 @@ describe("TreeView Props", () => {
346346 expect ( node2 ) . toHaveClass ( "bx--tree-node--active" ) ;
347347 } ) ;
348348
349+ describe ( "active node label indentation regression" , ( ) => {
350+ it ( "applies correct offset to root-level leaf node label (prevents active indicator clipping)" , ( ) => {
351+ render ( TreeViewProps , { activeId : 1 } ) ;
352+
353+ const activeNode = screen . getByRole ( "treeitem" , { name : / N o d e 2 / } ) ;
354+ const label = activeNode . querySelector ( ".bx--tree-node__label" ) ;
355+ expect . assert ( label instanceof HTMLElement ) ;
356+ expect ( label . style . paddingLeft ) . toBe ( "2.5rem" ) ;
357+ expect ( label . style . marginLeft ) . toBe ( "-2.5rem" ) ;
358+ } ) ;
359+
360+ it ( "applies correct offset to nested leaf node label when expanded" , ( ) => {
361+ render ( TreeViewProps , {
362+ activeId : 5 ,
363+ expandedIds : [ 1 ] ,
364+ nodes : [
365+ { id : 0 , text : "Node 1" } ,
366+ {
367+ id : 1 ,
368+ text : "Node 2" ,
369+ nodes : [
370+ { id : 2 , text : "Node 2a" } ,
371+ { id : 5 , text : "Node 2b" } ,
372+ ] ,
373+ } ,
374+ ] ,
375+ } ) ;
376+
377+ const activeNode = screen . getByRole ( "treeitem" , { current : true } ) ;
378+ const label = activeNode . querySelector ( ".bx--tree-node__label" ) ;
379+ expect . assert ( label instanceof HTMLElement ) ;
380+ // Nested at depth 2: offset = (2 - 1) + 2.5 = 3.5rem
381+ expect ( label . style . paddingLeft ) . toBe ( "3.5rem" ) ;
382+ expect ( label . style . marginLeft ) . toBe ( "-3.5rem" ) ;
383+ } ) ;
384+
385+ it ( "applies correct offset to root-level parent node label" , ( ) => {
386+ render ( TreeViewProps , {
387+ activeId : 1 ,
388+ nodes : [
389+ { id : 0 , text : "Node 1" } ,
390+ {
391+ id : 1 ,
392+ text : "Node 2" ,
393+ nodes : [ { id : 2 , text : "Node 2a" } ] ,
394+ } ,
395+ ] ,
396+ } ) ;
397+
398+ const activeNode = screen . getByRole ( "treeitem" , { name : / N o d e 2 / } ) ;
399+ const label = activeNode . querySelector ( ".bx--tree-node__label" ) ;
400+ expect . assert ( label instanceof HTMLElement ) ;
401+ // Root parent: offset = (1 - 1) + 1 = 1rem
402+ expect ( label . style . paddingLeft ) . toBe ( "1rem" ) ;
403+ expect ( label . style . marginLeft ) . toBe ( "-1rem" ) ;
404+ } ) ;
405+ } ) ;
406+
349407 it ( "handles multiple selectedIds" , ( ) => {
350408 render ( TreeViewMultiselect , { selectedIds : [ 0 , 7 , 9 ] } ) ;
351409
0 commit comments