Skip to content

Commit

Permalink
Improving Hotkeys for query input
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiadlovskii committed Jan 13, 2025
1 parent a0f8ece commit b811657
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const KeySeparator = styled.div`
const keyMapper = (key: string, isMacOS: boolean) => {
const keyMap = {
mod: isMacOS ? '⌘' : 'Ctrl',
alt: isMacOS ? '⌥' : 'Alt',
ctrl: isMacOS ? '⌃' : 'Ctrl',
meta: isMacOS ? '⌘' : 'Win',
};

return keyMap[key] || key;
Expand Down
3 changes: 2 additions & 1 deletion graylog2-web-interface/src/contexts/HotkeysProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Immutable from 'immutable';

import type { ScopeName, ActiveHotkeys, HotkeyCollections, Options } from 'contexts/HotkeysContext';
import HotkeysContext from 'contexts/HotkeysContext';
import { isMacOS } from 'util/OSUtils';

const viewActions = {
undo: { keys: 'mod+shift+z', description: 'Undo last action' },
Expand Down Expand Up @@ -68,7 +69,7 @@ export const hotKeysCollections: HotkeyCollections = {
'submit-search': { keys: 'return', description: 'Execute the search' },
'insert-newline': { keys: 'shift+return', description: 'Create a new line' },
'create-search-filter': { keys: 'alt+return', description: 'Create search filter based on current query' },
'show-suggestions': { keys: 'alt+space', description: 'Show suggestions, displays query history when input is empty' },
'show-suggestions': { keys: isMacOS() ? 'alt+space' : 'mod+space', description: 'Show suggestions, displays query history when input is empty' },
'show-history': { keys: 'alt+shift+h', description: 'View your search query history' },
},
},
Expand Down
2 changes: 1 addition & 1 deletion graylog2-web-interface/src/util/OSUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
*/

// eslint-disable-next-line import/prefer-default-export
export const isMacOS = () => navigator.userAgent.indexOf('Mac OS X') !== -1;
export const isMacOS = () => /Macintosh|MacIntel/.test(navigator.userAgent);
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const QueryInput = React.forwardRef<Editor, Props>(({
},
{
name: 'Show completions',
bindKey: { win: 'Alt-Space', mac: 'Alt-Space' },
bindKey: { win: 'Ctrl-Space', mac: 'Alt-Space' },
exec: async (editor: Editor) => {
if (editor.getValue()) {
startAutocomplete(editor);
Expand Down

0 comments on commit b811657

Please sign in to comment.