mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-10 10:47:20 +00:00
d47d13f041
Replace the previous hardcoded offset approach with a dedicated hook that dynamically centers the reaction toolbar relative to the reaction toggle. This improves layout accuracy and removes reliance on fixed values. Note: ResizeObserver is used for positioning updates and may not be supported in older browsers. Additional testing will be performed before production release. Replace direct DOM queries using hardcoded IDs with proper constants.
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { useCallback } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { RiEmotionLine } from '@remixicon/react'
|
|
import { ToggleButton } from '@/primitives'
|
|
|
|
import { useRegisterKeyboardShortcut } from '@/features/shortcuts/useRegisterKeyboardShortcut'
|
|
import { REACTIONS_TOOLBAR_ID } from '../constants'
|
|
import { useReactionsToolbar } from '../hooks/useReactionsToolbar'
|
|
import { layoutStore } from '@/stores/layout'
|
|
|
|
const focusReactionsToolbar = () => {
|
|
document
|
|
.getElementById(REACTIONS_TOOLBAR_ID)
|
|
?.querySelector<HTMLElement>('button')
|
|
?.focus()
|
|
}
|
|
|
|
export const REACTIONS_TOGGLE_ID = 'reactions-toggle'
|
|
|
|
export const ReactionsToggle = () => {
|
|
const { t } = useTranslation('rooms', { keyPrefix: 'controls.reactions' })
|
|
|
|
const { isOpen, toggle } = useReactionsToolbar()
|
|
|
|
const handleShortcut = useCallback(() => {
|
|
if (layoutStore.showReactionsToolbar) {
|
|
focusReactionsToolbar()
|
|
} else {
|
|
layoutStore.showReactionsToolbar = true
|
|
}
|
|
}, [])
|
|
|
|
useRegisterKeyboardShortcut({
|
|
id: 'reaction',
|
|
handler: handleShortcut,
|
|
})
|
|
|
|
return (
|
|
<ToggleButton
|
|
id={REACTIONS_TOGGLE_ID}
|
|
data-attr="reactions-toggle"
|
|
square
|
|
variant="primaryDark"
|
|
aria-label={t('button')}
|
|
aria-expanded={isOpen}
|
|
tooltip={t('button')}
|
|
isSelected={isOpen}
|
|
onChange={toggle}
|
|
>
|
|
<RiEmotionLine />
|
|
</ToggleButton>
|
|
)
|
|
}
|