{choices.length > 0 || displayCustomValue ? (
<>
@@ -219,11 +230,15 @@ const SingleAutocompleteSelectFieldContent: React.FC<
)}
- 0
- })}
- />
+
);
};
diff --git a/src/hooks/useElementScroll.ts b/src/hooks/useElementScroll.ts
index 0804d824e..83392800c 100644
--- a/src/hooks/useElementScroll.ts
+++ b/src/hooks/useElementScroll.ts
@@ -1,20 +1,30 @@
import throttle from "lodash-es/throttle";
import { MutableRefObject, useEffect, useState } from "react";
-function getPosition(anchor?: HTMLElement) {
+export type Position = Record<"x" | "y", number>;
+
+function getPosition(anchor?: HTMLElement): Position {
if (!!anchor) {
return {
x: anchor.scrollLeft,
y: anchor.scrollTop
};
}
- return {
- x: 0,
- y: 0
- };
+ return undefined;
}
-function useElementScroll(anchor: MutableRefObject
) {
+export function isScrolledToBottom(
+ anchor: MutableRefObject,
+ position: Position,
+ offset: number = 0
+) {
+ return !!anchor.current && position
+ ? position.y + anchor.current.clientHeight + offset >=
+ anchor.current.scrollHeight
+ : false;
+}
+
+function useElementScroll(anchor: MutableRefObject): Position {
const [scroll, setScroll] = useState(getPosition(anchor.current));
useEffect(() => {
diff --git a/src/utils/handlers/singleAutocompleteSelectChangeHandler.ts b/src/utils/handlers/singleAutocompleteSelectChangeHandler.ts
index ee2265185..1f95c8a54 100644
--- a/src/utils/handlers/singleAutocompleteSelectChangeHandler.ts
+++ b/src/utils/handlers/singleAutocompleteSelectChangeHandler.ts
@@ -10,7 +10,8 @@ function createSingleAutocompleteSelectHandler(
change(event);
const value = event.target.value;
- setSelected(choices.find(category => category.value === value).label);
+ const choice = choices.find(category => category.value === value)
+ setSelected(choice ? choice.label : value);
};
}