Skip to content

Commit

Permalink
fix: prevent intro box from displaying when filtering files
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcl-io committed Apr 29, 2021
1 parent 8df3366 commit 1f80bf7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/containers/Sidebar/Files/FilterFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FormControl, makeStyles } from '@material-ui/core';
import SingleLineInput from '../../../components/Input/SingleLineInput';

interface Props {
onChange: (input: string) => void;
onChange: (input: string | null) => void;
}

const FilterFiles = (props: Props) => {
Expand All @@ -15,7 +15,10 @@ const FilterFiles = (props: Props) => {
variant='outlined'
autoComplete='off'
size='small'
onChange={(e) => props.onChange(e.currentTarget.value)}
onChange={(e) => {
const { value } = e.currentTarget;
props.onChange(value === '' ? null : value);
}}
/>
</FormControl>
);
Expand Down
16 changes: 8 additions & 8 deletions src/containers/Sidebar/Files/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Files = () => {
const theme = useTheme();
const classes = useStyles();

const [filter, setFilter] = React.useState<string>('');
const [filter, setFilter] = React.useState<string | null>(null);
const [emptyTrashConfirm, setEmptyTrashConfirm] = React.useState(false);

const fileCollection = useStoreState((s) => s.fileCollection);
Expand All @@ -28,7 +28,7 @@ const Files = () => {
// Reset filter when changing folders
React.useEffect(() => {
if (activeFolderId !== 'all') {
setFilter('');
setFilter(null);
}
// eslint-disable-next-line
}, [activeFolderId]);
Expand Down Expand Up @@ -77,13 +77,13 @@ const Files = () => {
case 'all':
return {
key: '0',
primaryText: (
primaryText: filter ? (
<Box color={theme.palette.text.hint}>Empty result.</Box>
) : (
<NotifBox>
<>
You don't have any notes yet.
<br />
Press the <b>New Note</b> button to add a new note.
</>
You don't have any notes yet.
<br />
Press the <b>New Note</b> button to add a new note.
</NotifBox>
),
};
Expand Down

0 comments on commit 1f80bf7

Please sign in to comment.