Skip to content

Commit

Permalink
Merge pull request #85 from KilleenCode/70-close-omnibar-on-esc
Browse files Browse the repository at this point in the history
feat: close omnibar on escape
  • Loading branch information
RyKilleen authored Jul 24, 2022
2 parents ca8e84b + 709964d commit 0955a46
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 227 deletions.
446 changes: 229 additions & 217 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "brancato",
"version": "0.10.0",
"version": "0.11.0",
"private": true,
"dependencies": {
"@algolia/autocomplete-js": "^1.5.3",
"@algolia/autocomplete-theme-classic": "^1.5.3",
"@algolia/autocomplete-js": "^1.7.1",
"@algolia/autocomplete-theme-classic": "^1.7.1",
"@radix-ui/colors": "^0.1.8",
"@radix-ui/react-tabs": "^0.1.5",
"@stitches/react": "^1.2.7",
Expand All @@ -17,7 +17,7 @@
"@types/node": "^16.11.26",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.13",
"hotkeys-js": "^3.8.7",
"hotkeys-js": "^3.9.4",
"keycode": "^2.2.1",
"lodash": "^4.17.21",
"math-expression-evaluator": "^1.3.14",
Expand All @@ -33,7 +33,8 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"tauri": "tauri"
"tauri": "tauri",
"dev": "tauri dev"
},
"eslintConfig": {
"extends": [
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "brancato"
version = "0.10.0"
version = "0.11.0"
description = "A tool for stage-managing your life"
authors = ["Ryan Killeen"]
license = ""
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"productName": "brancato",
"version": "0.10.0"
"version": "0.11.0"
},
"build": {
"distDir": "../build",
Expand Down
10 changes: 9 additions & 1 deletion src/components/Autocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { autocomplete } from '@algolia/autocomplete-js';
import React, { createElement, Fragment, useEffect, useRef } from 'react';
import { render } from 'react-dom';
import "@algolia/autocomplete-theme-classic";
import { appWindow } from '@tauri-apps/api/window';

export const Action = ({ hit }) => {
// Component to display the items
Expand Down Expand Up @@ -34,12 +35,19 @@ export const Action = ({ hit }) => {
export function Autocomplete(props) {

const containerRef = useRef(null);
const handleEscape = (e) => {
if (e.key === 'Escape') {
appWindow.hide()
}
}

useEffect(() => {
if (!containerRef.current) {
return undefined;
}



const search = autocomplete({
detachedMediaQuery: 'none',
container: containerRef.current,
Expand All @@ -55,5 +63,5 @@ export function Autocomplete(props) {
};
}, [props, containerRef]);

return <div ref={containerRef} />;
return <div ref={containerRef} onKeyDown={handleEscape}/>;
}
3 changes: 2 additions & 1 deletion src/components/Omnibar/Omnibar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import createWebSearchSource, { searchEngines } from "./websearch-source";
import mexp from "math-expression-evaluator";
import createCalculatorSource from "./math-source";
import { UnlistenFn } from "@tauri-apps/api/event";

const focusSearchBar = () => {
let input = document.querySelector(".aa-Input") as HTMLElement | null;
let input = document.querySelector<HTMLInputElement>(".aa-Input");
input?.focus();
};

Expand Down

0 comments on commit 0955a46

Please sign in to comment.