feat(ui) - auto complete debounce issue fix
This commit is contained in:
parent
75b0351dfd
commit
1391b741b2
2 changed files with 23 additions and 22 deletions
|
|
@ -84,7 +84,7 @@ function LiveSessionList(props: Props) {
|
|||
title={"No live sessions."}
|
||||
subtext={
|
||||
<span>
|
||||
See how to <a target="_blank" className="link" href="https://docs.openreplay.com/plugins/assist">{'enable Assist'}</a> and ensure you're using tracker-assist v3.5.0 or higher.
|
||||
See how to <a target="_blank" className="link" href="https://docs.openreplay.com/plugins/assist">{'enable Assist'}</a> and ensure you're using tracker-assist <span className="font-medium">v3.5.0</span> or higher.
|
||||
</span>
|
||||
}
|
||||
image={<img src="/img/live-sessions.png"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ const hiddenStyle = {
|
|||
opacity: 0, position: 'fixed', left: '-3000px'
|
||||
};
|
||||
|
||||
let debouncedRequestValues = (value) => null;
|
||||
|
||||
interface Props {
|
||||
showOrButton?: boolean;
|
||||
showCloseButton?: boolean;
|
||||
|
|
@ -45,22 +47,24 @@ function FilterAutoComplete(props: Props) {
|
|||
const [query, setQuery] = useState(value);
|
||||
|
||||
|
||||
const requestValues = (q) => {
|
||||
setLoading(true);
|
||||
|
||||
return new APIClient()[method?.toLowerCase()](endpoint, { ...params, q })
|
||||
.then(response => response.json())
|
||||
.then(({ errors, data }) => {
|
||||
if (errors) {
|
||||
// this.setError();
|
||||
} else {
|
||||
setOptions(data);
|
||||
}
|
||||
}).finally(() => setLoading(false));
|
||||
// .catch(this.setError);
|
||||
}
|
||||
|
||||
const debouncedRequestValues = debounce(requestValues, 1000)
|
||||
useEffect(() => {
|
||||
const requestValues = (q) => {
|
||||
setLoading(true);
|
||||
|
||||
return new APIClient()[method?.toLowerCase()](endpoint, { ...params, q })
|
||||
.then(response => response.json())
|
||||
.then(({ errors, data }) => {
|
||||
if (errors) {
|
||||
// this.setError();
|
||||
} else {
|
||||
setOptions(data);
|
||||
}
|
||||
}).finally(() => setLoading(false));
|
||||
|
||||
}
|
||||
|
||||
debouncedRequestValues = debounce(requestValues, 1000)
|
||||
}, [])
|
||||
|
||||
const onInputChange = ({ target: { value } }) => {
|
||||
setQuery(value);
|
||||
|
|
@ -136,11 +140,8 @@ function FilterAutoComplete(props: Props) {
|
|||
|
||||
{ !showOrButton && <div className="ml-3">or</div> }
|
||||
|
||||
{/* <textarea style={hiddenStyle} ref={(ref) => this.hiddenInput = ref }></textarea> */}
|
||||
|
||||
{ showModal &&
|
||||
{ (showModal && (options.length > 0) || loading) && (
|
||||
<div className={ stl.menu }>
|
||||
{ headerText && headerText }
|
||||
<Loader loading={loading} size="small">
|
||||
{
|
||||
options.map((item, i) => (
|
||||
|
|
@ -156,7 +157,7 @@ function FilterAutoComplete(props: Props) {
|
|||
}
|
||||
</Loader>
|
||||
</div>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue