🩹(frontend) fix reaction toolbar refocusing first button on click

The toolbar's onFocus handler called focusManager.focusFirst() whenever
focus arrived from outside the toolbar, which included clicks on
reaction buttons. This caused focus (and the scroll viewport) to snap
back to the first button on every click.

Use :focus-visible to distinguish keyboard focus from pointer focus.
Only redirect to the first button when focus arrives via keyboard,
leaving click-induced focus untouched.

Co-authored-by: Cyril <c.gromoff@gmail.com>
This commit is contained in:
lebaudantoine
2026-05-21 22:26:50 +02:00
committed by aleb_the_flash
parent e21da647a0
commit 4830ea5673
@@ -20,6 +20,7 @@ export const ReactionsKeyboardNavigation = ({
const { close } = useReactionsToolbar()
const onFocus = (e: React.FocusEvent<HTMLDivElement>) => {
if (!e.target.matches(':focus-visible')) return
const comingFromOutside = !e.currentTarget.contains(e.relatedTarget)
if (comingFromOutside) {
focusManager?.focusFirst()