Skip to content

Commit

Permalink
fix keyboard shortcut for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Yasonik committed Sep 10, 2020
1 parent dede90e commit 5bd40cf
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function SearchBar({ globalSearch, navigateToUrl }: Props) {
const [searchValue, setSearchValue] = useState<string>('');
const [searchRef, setSearchRef] = useState<HTMLInputElement | null>(null);
const [options, _setOptions] = useState([] as EuiSelectableTemplateSitewideOption[]);
const isWindows = navigator.platform.toLowerCase().indexOf('win') >= 0;
const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0;

const setOptions = useCallback(
(_options: GlobalSearchResult[]) => {
Expand Down Expand Up @@ -106,7 +106,7 @@ export function SearchBar({ globalSearch, navigateToUrl }: Props) {
);

const onKeyDown = (event: KeyboardEvent) => {
if (event.key === '/' && (isWindows ? event.ctrlKey : event.metaKey)) {
if (event.key === '/' && (isMac ? event.metaKey : event.ctrlKey)) {
if (searchRef) {
event.preventDefault();
searchRef.focus();
Expand Down Expand Up @@ -176,7 +176,7 @@ export function SearchBar({ globalSearch, navigateToUrl }: Props) {
what: <EuiFlexItem grow={false}>Shortcut</EuiFlexItem>,
how: (
<EuiFlexItem grow={false}>
<EuiBadge>{isWindows ? 'Control + /' : 'Command + /'}</EuiBadge>
<EuiBadge>{isMac ? 'Command + /' : 'Control + /'}</EuiBadge>
</EuiFlexItem>
),
}}
Expand Down

0 comments on commit 5bd40cf

Please sign in to comment.