[arvados-workbench2] updated: 2.4.0-253-gcbe48311
git repository hosting
git at public.arvados.org
Wed Oct 19 17:20:02 UTC 2022
Summary of changes:
src/components/search-input/search-input.test.tsx | 9 ++++++++-
src/components/search-input/search-input.tsx | 12 +++---------
2 files changed, 11 insertions(+), 10 deletions(-)
via cbe483113381e8c22b28a042479f5b7374a84744 (commit)
from a9a30db7ec9505450da696ccf660edc20fe2ac0b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cbe483113381e8c22b28a042479f5b7374a84744
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Wed Oct 19 19:19:37 2022 +0200
19311: changed search component to a functional style
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/src/components/search-input/search-input.test.tsx b/src/components/search-input/search-input.test.tsx
index 0cb56ea1..ff1d30c4 100644
--- a/src/components/search-input/search-input.test.tsx
+++ b/src/components/search-input/search-input.test.tsx
@@ -98,10 +98,17 @@ describe("<SearchInput />", () => {
describe("on input target change", () => {
it("clears the input value on selfClearProp change", () => {
const searchInput = mount(<SearchInput selfClearProp="abc" value="123" onSearch={onSearch} debounce={1000}/>);
- searchInput.setProps({ selfClearProp: '111' });
+
+ // component should clear value upon creation
jest.runTimersToTime(1000);
expect(onSearch).toBeCalledWith("");
expect(onSearch).toHaveBeenCalledTimes(1);
+
+ // component should clear on selfClearProp change
+ searchInput.setProps({ selfClearProp: '111' });
+ jest.runTimersToTime(1000);
+ expect(onSearch).toBeCalledWith("");
+ expect(onSearch).toHaveBeenCalledTimes(2);
});
});
});
diff --git a/src/components/search-input/search-input.tsx b/src/components/search-input/search-input.tsx
index f7007b69..8d86307a 100644
--- a/src/components/search-input/search-input.tsx
+++ b/src/components/search-input/search-input.tsx
@@ -45,17 +45,10 @@ interface SearchInputActionProps {
type SearchInputProps = SearchInputDataProps & SearchInputActionProps & WithStyles<CssRules>;
-// interface SearchInputState {
-// value: string;
-// label: string;
-// }
-
-// let selfClearPropState = '';
-
export const DEFAULT_SEARCH_DEBOUNCE = 1000;
const SearchInputComponent = (props: SearchInputProps) => {
- const [timeout, setTimeout] = useState(1);
+ const [timeout, setTimeout] = useState(0);
const [value, setValue] = useState("");
const [label, setLabel] = useState("Search");
const [selfClearProp, setSelfClearProp] = useState("");
@@ -92,11 +85,12 @@ const SearchInputComponent = (props: SearchInputProps) => {
const { target: { value: eventValue } } = event;
clearTimeout(timeout);
setValue(eventValue);
+
setTimeout(window.setTimeout(
() => {
props.onSearch(eventValue);
},
- props.debounce || DEFAULT_SEARCH_DEBOUNCE
+ props.debounce || DEFAULT_SEARCH_DEBOUNCE
));
};
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list