@@ -78,7 +78,7 @@ const selectedOption = ref(null);
7878const handleSelect = (item , option ) => {
7979 closeDropdowns ();
8080 const value = item .dropdownValueKey .value ? option[item .dropdownValueKey .value ] : option .label ;
81- emit (' command' , { item, argument: value, option });
81+ emit (' command' , { item, argument: value, option, switchFocusToEditor : true });
8282 selectedOption .value = option .key ;
8383};
8484
@@ -132,6 +132,12 @@ const moveToNextButtonGroup = (e) => {
132132 if (nextButtonGroup) {
133133 nextButtonGroup .setAttribute (' tabindex' , ' 0' );
134134 nextButtonGroup .focus ();
135+ } else {
136+ // Move to the editor
137+ const editor = document .querySelector (' .ProseMirror' );
138+ if (editor) {
139+ editor .focus ();
140+ }
135141 }
136142};
137143
@@ -149,16 +155,19 @@ const moveToPreviousButtonGroup = (e) => {
149155// Set tabindex to -1 for all other buttons
150156const handleKeyDown = (e , item ) => {
151157 e .preventDefault ();
152- e .stopPropagation ();
153-
154158 switch (e .key ) {
155159 case ' Enter' :
156160 handleToolbarButtonClick (item, null , false );
157161 break ;
162+ case ' Escape' :
163+ closeDropdowns ();
164+ break ;
158165 case ' ArrowRight' :
166+ closeDropdowns ();
159167 moveToNextButton (e);
160168 break ;
161169 case ' ArrowLeft' :
170+ closeDropdowns ();
162171 moveToPreviousButton (e);
163172 break ;
164173 case ' Tab' :
@@ -176,7 +185,6 @@ const handleFocus = (e) => {
176185 // Set the focus to the first button inside the button group that is not disabled
177186 const firstButton = e .target .closest (' .button-group' ).querySelector (' .toolbar-item-ctn:not(.disabled)' );
178187 if (firstButton) {
179- // Force focus on the first button
180188 firstButton .focus ();
181189 }
182190};
@@ -187,7 +195,7 @@ const handleFocus = (e) => {
187195 : style= " getPositionStyle"
188196 class = " button-group"
189197 role= " group"
190- @focus= " (e) => handleFocus(e) "
198+ @focus= " handleFocus"
191199 >
192200 < div
193201 v- for = " (item, index) in toolbarItems"
0 commit comments