Skip to content
Snippets Groups Projects
Unverified Commit 53db2f65 authored by Douglas Fabris's avatar Douglas Fabris Committed by GitHub
Browse files

regression: Focus the most recent message instead of the first on message list (#32049)

parent e203c404
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ export const useMessageListNavigation = (): { messageListRef: RefCallback<HTMLEl
(node: HTMLElement | null) => {
let lastMessageFocused: HTMLElement | null = null;
let triggeredByKeyboard = false;
let initialFocus = true;
if (!node) {
return;
......@@ -70,8 +71,9 @@ export const useMessageListNavigation = (): { messageListRef: RefCallback<HTMLEl
}
lastMessageFocused = document.activeElement as HTMLElement;
triggeredByKeyboard = true;
}
triggeredByKeyboard = true;
});
node.addEventListener(
......@@ -91,6 +93,13 @@ export const useMessageListNavigation = (): { messageListRef: RefCallback<HTMLEl
node.addEventListener(
'focus',
(e) => {
if (initialFocus) {
lastMessageFocused = node?.querySelector('li:last-child > [role=link]:first-child');
lastMessageFocused?.focus();
lastMessageFocused = null;
initialFocus = false;
}
if (!triggeredByKeyboard || !(e.currentTarget instanceof HTMLElement && e.relatedTarget instanceof HTMLElement)) {
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment