diff --git a/app/src/components/Channels.js b/app/src/components/Channels.js
index 40ab5752..ce11c386 100644
--- a/app/src/components/Channels.js
+++ b/app/src/components/Channels.js
@@ -3,7 +3,6 @@ import {
AccordionContent,
AccordionTitle,
Grid,
- Input,
StatisticLabel,
StatisticValue,
TableCell,
@@ -18,7 +17,9 @@ import {
frequencyOptions,
humanFileSize,
RequiredAsterisk,
- secondsToFrequency, secondsToFullDuration,
+ SearchInput,
+ secondsToFrequency,
+ secondsToFullDuration,
Toggle,
useTitle,
WROLModeMessage
@@ -26,7 +27,7 @@ import {
import {Link, useNavigate, useParams} from "react-router-dom";
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
-import {useChannel, useChannels} from "../hooks/customHooks";
+import {useChannel, useChannels, useOneQuery} from "../hooks/customHooks";
import _ from "lodash";
import {Accordion, Button, Form, FormField, FormGroup, FormInput, Header, Loader, Segment, Statistic} from "./Theme";
import Dropdown from "semantic-ui-react/dist/commonjs/modules/Dropdown";
@@ -500,25 +501,20 @@ export function ChannelsPage() {
useTitle('Channels');
const {channels} = useChannels();
- const [searchStr, setSearchStr] = useState('');
+ const [searchStr, setSearchStr] = useOneQuery('name');
- const handleInputChange = (e, {value}) => {
- e.preventDefault();
- setSearchStr(value);
- }
-
- let header =
-
+ const header =
-
+ setSearchStr('')}
+ onChange={setSearchStr}/>
diff --git a/app/src/components/Common.js b/app/src/components/Common.js
index d457d862..a158764a 100644
--- a/app/src/components/Common.js
+++ b/app/src/components/Common.js
@@ -406,15 +406,33 @@ export function SearchInput({
clearable,
autoFocus = false,
onClear = null,
+ onChange = null,
...props
}) {
let [value, setValue] = useState(searchStr || '');
+ const handleChange = (e) => {
+ if (e) {
+ e.preventDefault();
+ }
+ setValue(e.target.value);
+ if (onChange) {
+ // Try to call the remote function, don't let its failure break this.
+ try {
+ onChange(e.target.value);
+ } catch (e) {
+ console.error(`Call to ${onChange} failed`);
+ }
+ }
+ }
+
const handleClearSearch = (e) => {
e.preventDefault();
// Clear the input when the "clear" button is clicked, search again.
setValue('');
- onSubmit('');
+ if (onSubmit) {
+ onSubmit('');
+ }
if (onClear) {
onClear();
}
@@ -423,7 +441,11 @@ export function SearchInput({
const localOnSubmit = (e) => {
// Send the value up when submitting.
e.preventDefault();
- onSubmit(value);
+ if (onSubmit) {
+ onSubmit(value);
+ } else {
+ console.debug('No onSubmit defined');
+ }
}
if ((action || actionIcon) && searchStr && searchStr === value && clearable) {
@@ -438,7 +460,7 @@ export function SearchInput({
setValue(e.target.value)}
+ onChange={handleChange}
value={value}
size={size}
action={action}
diff --git a/app/src/hooks/customHooks.js b/app/src/hooks/customHooks.js
index 47a5d358..cdb9e40a 100644
--- a/app/src/hooks/customHooks.js
+++ b/app/src/hooks/customHooks.js
@@ -92,6 +92,7 @@ export const useOneQuery = (name) => {
const value = searchParams.get(name);
const setValue = (newValue) => {
+ console.debug(`useOneQuery setValue=${newValue}`);
updateQuery({[name]: newValue});
}