@@ -12,6 +12,7 @@ import { Box, BoxButton, Icon, Text } from '@/components';
12
12
import { useCunninghamTheme } from '@/cunningham' ;
13
13
import { Doc , useTrans } from '@/features/docs/doc-management' ;
14
14
import { useActionableMode } from '@/features/docs/doc-tree/hooks/useActionableMode' ;
15
+ import { useLoadChildrenOnOpen } from '@/features/docs/doc-tree/hooks/useLoadChildrenOnOpen' ;
15
16
import { useLeftPanelStore } from '@/features/left-panel' ;
16
17
import { useResponsiveStore } from '@/stores' ;
17
18
@@ -40,8 +41,8 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
40
41
const { t } = useTranslation ( ) ;
41
42
42
43
const [ menuOpen , setMenuOpen ] = useState ( false ) ;
43
-
44
- const isActive = node . isFocused || menuOpen ;
44
+ const isSelectedNow = treeContext ?. treeData . selectedNode ?. id === doc . id ;
45
+ const isActive = node . isFocused || menuOpen || isSelectedNow ;
45
46
46
47
const router = useRouter ( ) ;
47
48
const { togglePanel } = useLeftPanelStore ( ) ;
@@ -81,13 +82,25 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
81
82
}
82
83
} ;
83
84
84
- useKeyboardActivation ( [ 'Enter' , ' ' ] , isActive , handleActivate , true ) ;
85
+ useKeyboardActivation (
86
+ [ 'Enter' , ' ' ] ,
87
+ isActive && ! menuOpen ,
88
+ handleActivate ,
89
+ true ,
90
+ ) ;
91
+ useLoadChildrenOnOpen (
92
+ node . data . value . id ,
93
+ node . isOpen ,
94
+ treeContext ?. treeData . handleLoadChildren ,
95
+ treeContext ?. treeData . setChildren ,
96
+ ( doc . children ?. length ?? 0 ) > 0 || doc . childrenCount === 0 ,
97
+ ) ;
85
98
86
99
// prepare the text for the screen reader
87
100
const docTitle = doc . title || untitledDocument ;
88
101
const hasChildren = ( doc . children ?. length || 0 ) > 0 ;
89
102
const isExpanded = node . isOpen ;
90
- const isSelected = treeContext ?. treeData . selectedNode ?. id === doc . id ;
103
+ const isSelected = isSelectedNow ;
91
104
92
105
const ariaLabel = `${ docTitle } ${ hasChildren ? `, ${ isExpanded ? t ( 'expanded' ) : t ( 'collapsed' ) } ` : '' } ${ isSelected ? `, ${ t ( 'selected' ) } ` : '' } ` ;
93
106
@@ -143,6 +156,15 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
143
156
background : var (--c--theme--colors--greyscale-100 );
144
157
}
145
158
}
159
+
160
+ /* Ensure actions are visible when hovering the whole item container */
161
+ & : hover {
162
+ .light-doc-item-actions {
163
+ display : flex;
164
+ opacity : 1 ;
165
+ visibility : visible;
166
+ }
167
+ }
146
168
` }
147
169
>
148
170
< TreeViewItem { ...props } onClick = { handleActivate } >
0 commit comments