Commit ef37f685 authored by Aron Fiechter's avatar Aron Fiechter
Browse files

Clear text from all input fields after a query or an advanced query

parent 41f818c0
import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { performQuery, selectError, selectQuery } from './querySlice';
import { performQuery, selectError } from './querySlice';
import { openModal } from '../search/searchSlice';
import Form from 'react-bootstrap/Form';
import Button from 'react-bootstrap/Button';
export default function Query(props) {
export default function Query() {
// The component state is just the query text (for now)
const previousQuery = useSelector(selectQuery);
const [text, setText] = useState(
previousQuery?.fields?.find((f) => f.key === 'allData')?.value || '',
);
const [text, setText] = useState('');
// Dispatch and selectors used in this component
const dispatch = useDispatch();
......@@ -25,7 +22,7 @@ export default function Query(props) {
if (!text.trim()) {
return;
}
dispatch(performQuery({ text }));
dispatch(performQuery({ text })).then(() => setText(''));
};
return (
......
......@@ -122,7 +122,7 @@ export default function SearchModal() {
};
}),
};
dispatch(performQuery(query));
dispatch(performQuery(query)).then(() => searchFields.forEach((f) => f.set('')));
handleClose();
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment