@@ -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,26 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
81
82
}
82
83
} ;
83
84
84
- useKeyboardActivation ( [ 'Enter' , ' ' ] , isActive , handleActivate , true ) ;
85
+ // Disable activation keys while the menu is open to avoid conflicts
86
+ useKeyboardActivation (
87
+ [ 'Enter' , ' ' ] ,
88
+ isActive && ! menuOpen ,
89
+ handleActivate ,
90
+ true ,
91
+ ) ;
92
+ useLoadChildrenOnOpen (
93
+ node . data . value . id ,
94
+ node . isOpen ,
95
+ treeContext ?. treeData . handleLoadChildren ,
96
+ treeContext ?. treeData . setChildren ,
97
+ ( doc . children ?. length ?? 0 ) > 0 || doc . childrenCount === 0 ,
98
+ ) ;
85
99
86
100
// prepare the text for the screen reader
87
101
const docTitle = doc . title || untitledDocument ;
88
102
const hasChildren = ( doc . children ?. length || 0 ) > 0 ;
89
103
const isExpanded = node . isOpen ;
90
- const isSelected = treeContext ?. treeData . selectedNode ?. id === doc . id ;
104
+ const isSelected = isSelectedNow ;
91
105
92
106
const ariaLabel = `${ docTitle } ${ hasChildren ? `, ${ isExpanded ? t ( 'expanded' ) : t ( 'collapsed' ) } ` : '' } ${ isSelected ? `, ${ t ( 'selected' ) } ` : '' } ` ;
93
107
@@ -143,6 +157,15 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
143
157
background : var (--c--theme--colors--greyscale-100 );
144
158
}
145
159
}
160
+
161
+ /* Ensure actions are visible when hovering the whole item container */
162
+ & : hover {
163
+ .light-doc-item-actions {
164
+ display : flex;
165
+ opacity : 1 ;
166
+ visibility : visible;
167
+ }
168
+ }
146
169
` }
147
170
>
148
171
< TreeViewItem { ...props } onClick = { handleActivate } >
0 commit comments