Skip to content

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

web: show reset search button only when query text present (#7950)

01zulfia62beab1724d
diff --git a/apps/web/src/components/field/index.tsx b/apps/web/src/components/field/index.tsx
index 2311dc3f2..282c9ea95 100644
--- a/apps/web/src/components/field/index.tsx
+++ b/apps/web/src/components/field/index.tsx
@@ -31,6 +31,7 @@ type Action = {
disabled?: boolean;
icon?: Icon;
component?: JSX.Element;
+ hidden?: boolean;
};
export type FieldProps = InputProps & {
label?: string;
@@ -65,8 +66,14 @@ function Field(props: FieldProps) {
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
const colorScheme = useThemeStore((state) => state.colorScheme);
const [isValid, setIsValid] = useState(true);
- const rightActions = props.rightActions || (action ? [action] : []);
- const leftActions = props.leftActions || [];
+ const rightActions = props.rightActions
+ ? props.rightActions.filter((a) => !a.hidden)
+ : action && !action.hidden
+ ? [action]
+ : [];
+ const leftActions = props.leftActions
+ ? props.leftActions.filter((a) => !a.hidden)
+ : [];
return (
<Flex
diff --git a/apps/web/src/components/route-container/index.tsx b/apps/web/src/components/route-container/index.tsx
index 932b37010..7c7dc47ea 100644
--- a/apps/web/src/components/route-container/index.tsx
+++ b/apps/web/src/components/route-container/index.tsx
@@ -141,7 +141,8 @@ function Header(props: RouteContainerProps) {
onClick: () => {
if (inputRef.current) inputRef.current.value = "";
useSearchStore.getState().resetSearch();
- }
+ },
+ hidden: !Boolean(query)
},
...(type === "reminders"
? [