File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
src/frontend/apps/impress/src/features/docs/doc-tree/components Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -100,14 +100,24 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
100100
101101 const handleKeyDown = ( e : React . KeyboardEvent ) => {
102102 // F2: focus first action button
103- const shoulOpenActions = ! menuOpen && node . isFocused ;
104- if ( e . key === 'F2' && shoulOpenActions ) {
103+ const shouldOpenActions = ! menuOpen && node . isFocused ;
104+ if ( e . key === 'F2' && shouldOpenActions ) {
105105 buttonOptionRef . current ?. focus ( ) ;
106106 e . stopPropagation ( ) ;
107107 return ;
108108 }
109109 } ;
110110
111+ const handleActionsOpenChange = ( isOpen : boolean ) => {
112+ setMenuOpen ( isOpen ) ;
113+
114+ // When the menu closes (via Escape or activating an option),
115+ // return focus to the tree item so focus is not lost.
116+ if ( ! isOpen ) {
117+ node . focus ( ) ;
118+ }
119+ } ;
120+
111121 return (
112122 < Box
113123 className = "--docs-sub-page-item"
@@ -181,7 +191,7 @@ export const DocSubPageItem = (props: TreeViewNodeProps<Doc>) => {
181191 < DocTreeItemActions
182192 doc = { doc }
183193 isOpen = { menuOpen }
184- onOpenChange = { setMenuOpen }
194+ onOpenChange = { handleActionsOpenChange }
185195 parentId = { node . data . parentKey }
186196 onCreateSuccess = { afterCreate }
187197 actionsRef = { actionsRef }
You can’t perform that action at this time.
0 commit comments