mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-22 04:28:33 +01:00
@@ -60,6 +60,7 @@ export const Ticket = (props) => {
|
||||
const [ticketChat, setTicketChat] = useState('');
|
||||
|
||||
const messagesEndRef: RefObject<HTMLDivElement | null> = useRef(null);
|
||||
const inputRef: RefObject<HTMLInputElement | null> = useRef(null);
|
||||
|
||||
const {
|
||||
id,
|
||||
@@ -78,20 +79,14 @@ export const Ticket = (props) => {
|
||||
|
||||
useEffect(() => {
|
||||
const scroll = messagesEndRef.current;
|
||||
if (scroll) {
|
||||
scroll.scrollTop = scroll.scrollHeight;
|
||||
}
|
||||
}, []);
|
||||
if (!scroll) return;
|
||||
|
||||
useEffect(() => {
|
||||
const scroll = messagesEndRef.current;
|
||||
if (scroll) {
|
||||
const height = scroll.scrollHeight;
|
||||
const bottom = scroll.scrollTop + scroll.offsetHeight;
|
||||
const scrollTracking = Math.abs(height - bottom) < 24;
|
||||
if (scrollTracking) {
|
||||
scroll.scrollTop = scroll.scrollHeight;
|
||||
}
|
||||
const isAtBottom =
|
||||
Math.abs(scroll.scrollHeight - scroll.scrollTop - scroll.offsetHeight) <
|
||||
24;
|
||||
|
||||
if (isAtBottom) {
|
||||
scroll.scrollTop = scroll.scrollHeight;
|
||||
}
|
||||
}, [log]);
|
||||
|
||||
@@ -203,6 +198,7 @@ export const Ticket = (props) => {
|
||||
ticket_ref: ticket_ref,
|
||||
});
|
||||
setTicketChat('');
|
||||
requestAnimationFrame(() => inputRef.current?.focus());
|
||||
}
|
||||
}}
|
||||
/>
|
||||
@@ -215,6 +211,7 @@ export const Ticket = (props) => {
|
||||
ticket_ref: ticket_ref,
|
||||
});
|
||||
setTicketChat('');
|
||||
requestAnimationFrame(() => inputRef.current?.focus());
|
||||
}}
|
||||
>
|
||||
Send
|
||||
|
||||
@@ -47,24 +47,19 @@ export const TicketChat = (props) => {
|
||||
const { id, level, handler, log } = data;
|
||||
|
||||
const messagesEndRef: RefObject<HTMLDivElement | null> = useRef(null);
|
||||
const inputRef: RefObject<HTMLInputElement | null> = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const scroll = messagesEndRef.current;
|
||||
if (scroll) {
|
||||
if (!scroll) return;
|
||||
|
||||
const isAtBottom =
|
||||
Math.abs(scroll.scrollHeight - scroll.scrollTop - scroll.offsetHeight) <
|
||||
24;
|
||||
|
||||
if (isAtBottom) {
|
||||
scroll.scrollTop = scroll.scrollHeight;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const scroll = messagesEndRef.current;
|
||||
if (scroll) {
|
||||
const height = scroll.scrollHeight;
|
||||
const bottom = scroll.scrollTop + scroll.offsetHeight;
|
||||
const scrollTracking = Math.abs(height - bottom) < 24;
|
||||
if (scrollTracking) {
|
||||
scroll.scrollTop = scroll.scrollHeight;
|
||||
}
|
||||
}
|
||||
}, [log]);
|
||||
|
||||
return (
|
||||
@@ -114,6 +109,7 @@ export const TicketChat = (props) => {
|
||||
autoFocus
|
||||
autoSelect
|
||||
fluid
|
||||
ref={inputRef}
|
||||
placeholder="Enter a message..."
|
||||
value={ticketChat}
|
||||
onChange={(value: string) => setTicketChat(value)}
|
||||
@@ -121,6 +117,7 @@ export const TicketChat = (props) => {
|
||||
if (KEY.Enter === e.key) {
|
||||
act('send_msg', { msg: ticketChat });
|
||||
setTicketChat('');
|
||||
requestAnimationFrame(() => inputRef.current?.focus());
|
||||
}
|
||||
}}
|
||||
/>
|
||||
@@ -130,6 +127,7 @@ export const TicketChat = (props) => {
|
||||
onClick={() => {
|
||||
act('send_msg', { msg: ticketChat });
|
||||
setTicketChat('');
|
||||
requestAnimationFrame(() => inputRef.current?.focus());
|
||||
}}
|
||||
>
|
||||
Send
|
||||
|
||||
@@ -108,24 +108,19 @@ export const TicketsPanel = (props) => {
|
||||
const [ticketChat, setTicketChat] = useState('');
|
||||
|
||||
const messagesEndRef: RefObject<HTMLDivElement | null> = useRef(null);
|
||||
const inputRef: RefObject<HTMLInputElement | null> = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const scroll = messagesEndRef.current;
|
||||
if (scroll) {
|
||||
if (!scroll) return;
|
||||
|
||||
const isAtBottom =
|
||||
Math.abs(scroll.scrollHeight - scroll.scrollTop - scroll.offsetHeight) <
|
||||
24;
|
||||
|
||||
if (isAtBottom) {
|
||||
scroll.scrollTop = scroll.scrollHeight;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const scroll = messagesEndRef.current;
|
||||
if (scroll) {
|
||||
const height = scroll.scrollHeight;
|
||||
const bottom = scroll.scrollTop + scroll.offsetHeight;
|
||||
const scrollTracking = Math.abs(height - bottom) < 24;
|
||||
if (scrollTracking) {
|
||||
scroll.scrollTop = scroll.scrollHeight;
|
||||
}
|
||||
}
|
||||
}, [selected_ticket?.log]);
|
||||
|
||||
const availableLevel = is_admin ? AdminLevel : MentorLevel;
|
||||
@@ -359,6 +354,7 @@ export const TicketsPanel = (props) => {
|
||||
autoFocus
|
||||
autoSelect
|
||||
fluid
|
||||
ref={inputRef}
|
||||
placeholder="Enter a message..."
|
||||
value={ticketChat}
|
||||
onChange={(value: string) => setTicketChat(value)}
|
||||
@@ -366,6 +362,9 @@ export const TicketsPanel = (props) => {
|
||||
if (KEY.Enter === e.key) {
|
||||
act('send_msg', { msg: ticketChat });
|
||||
setTicketChat('');
|
||||
requestAnimationFrame(() =>
|
||||
inputRef.current?.focus(),
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
@@ -375,6 +374,9 @@ export const TicketsPanel = (props) => {
|
||||
onClick={() => {
|
||||
act('send_msg', { msg: ticketChat });
|
||||
setTicketChat('');
|
||||
requestAnimationFrame(() =>
|
||||
inputRef.current?.focus(),
|
||||
);
|
||||
}}
|
||||
>
|
||||
Send
|
||||
|
||||
Reference in New Issue
Block a user