added autofocus feature for chat input div

This commit is contained in:
hariraghav10
2023-10-10 17:04:05 +05:30
parent 9cfcdb1c23
commit e48df87e06

View File

@@ -29,6 +29,16 @@ export default function Conversation() {
scrollIntoView();
}, [queries.length, queries[queries.length - 1]]);
useEffect(() => {
const element = document.getElementById('inputbox') as HTMLInputElement;
if (element) {
element.focus();
console.log("Element with ID 'inputbox' found");
} else {
console.log("Element with ID 'inputbox' not found");
}
}, []);
useEffect(() => {
const observerCallback: IntersectionObserverCallback = (entries) => {
entries.forEach((entry) => {
@@ -152,7 +162,9 @@ export default function Conversation() {
<div className="relative bottom-0 flex w-10/12 flex-col items-end self-center bg-white pt-3 md:fixed md:w-[65%]">
<div className="flex h-full w-full">
<div
id="inputbox"
ref={inputRef}
tabIndex={1}
placeholder="Type your message here..."
contentEditable
onPaste={handlePaste}