Skip to content

Commit

Permalink
fix: last message should be focused only when user enters a new conve…
Browse files Browse the repository at this point in the history
…rsation using keyboard(press enter) (#15814)
  • Loading branch information
arjita-mitra committed Sep 14, 2023
1 parent 41d57fc commit ea3aee4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/script/components/MessagesList/Message/index.tsx
Expand Up @@ -152,6 +152,11 @@ const Message: React.FC<
}
if (history.state?.eventKey === 'Enter') {
handleFocus(totalMessage - 1);

// reset the eventKey to stop focusing on every new message user send/receive afterwards
// last message should be focused only when user enters a new conversation using keyboard(press enter)
history.state.eventKey = '';
window.history.replaceState(history.state, '', window.location.hash);
}
}, [totalMessage]);

Expand All @@ -160,7 +165,7 @@ const Message: React.FC<
if (isMessageFocused) {
messageRef.current?.focus();
}
}, [isMessageFocused, message]);
}, [isMessageFocused]);

// set message elements focus for non content type mesages
// some non content type message has interactive element like invite people for member message
Expand Down

0 comments on commit ea3aee4

Please sign in to comment.