@@ -68,11 +68,22 @@ export default defineComponent({
6868 // Format hotkey for display
6969 const formattedHotkey = computed (() => {
7070 const hotkey = Array .isArray (props .hotkey ) ? props .hotkey [0 ] : props .hotkey ;
71- return hotkey
72- .toLowerCase ()
73- .split (' +' )
74- .map ((part ) => part .charAt (0 ).toUpperCase () + part .slice (1 ))
75- .join (' + ' );
71+ // Check if this is a sequence (has spaces) or a combination (has +)
72+ if (hotkey .includes (' ' )) {
73+ // For sequences like "g h", display as "G, H"
74+ return hotkey
75+ .toLowerCase ()
76+ .split (' ' )
77+ .map ((part ) => part .charAt (0 ).toUpperCase () + part .slice (1 ))
78+ .join (' , ' );
79+ } else {
80+ // For combinations like "ctrl+s", display as "Ctrl + S"
81+ return hotkey
82+ .toLowerCase ()
83+ .split (' +' )
84+ .map ((part ) => part .charAt (0 ).toUpperCase () + part .slice (1 ))
85+ .join (' + ' );
86+ }
7687 });
7788
7889 // Apply highlight effect to the actual button/control when Ctrl is pressed
@@ -115,16 +126,58 @@ export default defineComponent({
115126 const handleHotkeyPress = () => {
116127 if (props .disabled || ! wrapperElement .value ) return ;
117128
118- // Find the first clickable element within our wrapper
119- const clickableElement = wrapperElement .value .querySelector (
129+ // Try finding a clickable element within our wrapper
130+ let clickableElement = wrapperElement .value .querySelector (
120131 ' button, a, input[type="button"], [role="button"]'
121132 ) as HTMLElement ;
122133
134+ // If no standard clickable element found, try to find navigation or list items
135+ if (! clickableElement ) {
136+ clickableElement = wrapperElement .value .querySelector (
137+ ' v-list-item, .v-list-item, router-link, .router-link, a, [to]'
138+ ) as HTMLElement ;
139+ }
140+
141+ // If still no element found, try the wrapper itself - it might be clickable
142+ if (! clickableElement && (
143+ wrapperElement .value .hasAttribute (' to' ) ||
144+ wrapperElement .value .tagName === ' A' ||
145+ wrapperElement .value .classList .contains (' v-list-item' )
146+ )) {
147+ clickableElement = wrapperElement .value ;
148+ }
149+
150+ // Get closest parent list item or router link if we found a title/content element
151+ if (! clickableElement ) {
152+ const closestClickableParent = wrapperElement .value .closest (' v-list-item, .v-list-item, a, [to]' );
153+ if (closestClickableParent ) {
154+ clickableElement = closestClickableParent as HTMLElement ;
155+ }
156+ }
157+
123158 if (clickableElement ) {
124- clickableElement .click ();
125- emit (' hotkey-triggered' , props .hotkey );
159+ if (clickableElement .hasAttribute (' to' )) {
160+ // Handle router-link style navigation
161+ const routePath = clickableElement .getAttribute (' to' );
162+ if (routePath && window .location .pathname !== routePath ) {
163+ // Use parent router if available (Vue component)
164+ const router = (window as any ).$nuxt ?.$router || (window as any ).$router ;
165+ if (router && typeof router .push === ' function' ) {
166+ router .push (routePath );
167+ } else {
168+ // Fallback to regular navigation
169+ window .location .pathname = routePath ;
170+ }
171+ }
172+ emit (' hotkey-triggered' , props .hotkey );
173+ } else {
174+ // Regular click for standard elements
175+ clickableElement .click ();
176+ emit (' hotkey-triggered' , props .hotkey );
177+ }
126178 } else {
127179 // If no clickable element found, emit the event for parent handling
180+ console .log (' No clickable element found for hotkey' , props .hotkey );
128181 emit (' hotkey-triggered' , props .hotkey );
129182 }
130183 };
0 commit comments