Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: search input ui

thecodrre0bbf58cab6a
diff --git a/apps/web/src/components/field/index.js b/apps/web/src/components/field/index.js
index 3f2e68d8d..059e5f3cc 100644
--- a/apps/web/src/components/field/index.js
+++ b/apps/web/src/components/field/index.js
@@ -16,6 +16,7 @@ function Field(props) {
helpText,
action,
onKeyUp,
+ onKeyDown,
onChange,
inputRef,
defaultValue,
@@ -54,6 +55,7 @@ function Field(props) {
type={type || "text"}
onChange={onChange}
onKeyUp={onKeyUp}
+ onKeyDown={onKeyDown}
/>
{type === "password" && (
<Flex
diff --git a/apps/web/src/components/search/index.js b/apps/web/src/components/search/index.js
index 407d2c8b4..295bc955b 100644
--- a/apps/web/src/components/search/index.js
+++ b/apps/web/src/components/search/index.js
@@ -1,42 +1,29 @@
import React from "react";
-import { Flex, Box } from "rebass";
-import { Input } from "@rebass/forms";
import * as Icon from "../icons";
import "./search.css";
+import Field from "../field";
function SearchBox(props) {
- //const { query, type, context } = props;
-
return (
- <Flex
- variant="rowCenter"
- mx={2}
- mb={2}
- px={2}
- bg="bgSecondary"
- sx={{
- position: "relative",
- borderRadius: "default",
+ <Field
+ id="search"
+ name="search"
+ type="text"
+ sx={{ mx: 2 }}
+ placeholder="Type your query here"
+ onKeyDown={(e) => {
+ if (e.key === "Enter") props.onSearch(e.target.value);
+ }}
+ action={{
+ icon: Icon.Search,
+ onClick: () => {
+ const searchField = document.getElementById("search");
+ if (searchField && searchField.value && searchField.value.length) {
+ props.onSearch(searchField.value);
+ }
+ },
}}
- >
- <Input
- id="searchInput"
- name="search"
- sx={{ borderWidth: 0, px: 0 }}
- placeholder={`Type your query here`}
- onKeyDown={(e) => {
- if (e.key === "Enter") props.onSearch(e.target.value);
- }}
- />
- <Box
- id="searchIcon"
- sx={{
- color: "hover",
- }}
- >
- <Icon.Search size={24} />
- </Box>
- </Flex>
+ />
);
}
export default SearchBox;