mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-21 15:47:09 +00:00
✨(frontend) add auto refocus for effects menu
Restore focus to options button on close, focus first element on open
This commit is contained in:
@@ -169,7 +169,7 @@ export const SidePanel = () => {
|
|||||||
<Panel isOpen={isParticipantsOpen}>
|
<Panel isOpen={isParticipantsOpen}>
|
||||||
<ParticipantsList />
|
<ParticipantsList />
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel isOpen={isEffectsOpen}>
|
<Panel isOpen={isEffectsOpen} keepAlive={true}>
|
||||||
<Effects />
|
<Effects />
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel isOpen={isChatOpen} keepAlive={true}>
|
<Panel isOpen={isChatOpen} keepAlive={true}>
|
||||||
|
|||||||
@@ -5,14 +5,41 @@ import { EffectsConfiguration } from './EffectsConfiguration'
|
|||||||
import { usePersistentUserChoices } from '../../hooks/usePersistentUserChoices'
|
import { usePersistentUserChoices } from '../../hooks/usePersistentUserChoices'
|
||||||
import { useCanPublishTrack } from '@/features/rooms/livekit/hooks/useCanPublishTrack'
|
import { useCanPublishTrack } from '@/features/rooms/livekit/hooks/useCanPublishTrack'
|
||||||
import { TrackSource } from '@livekit/protocol'
|
import { TrackSource } from '@livekit/protocol'
|
||||||
|
import { useSidePanel } from '../../hooks/useSidePanel'
|
||||||
|
import { useRestoreFocus } from '@/hooks/useRestoreFocus'
|
||||||
|
|
||||||
export const Effects = () => {
|
export const Effects = () => {
|
||||||
const { cameraTrack } = useLocalParticipant()
|
const { cameraTrack } = useLocalParticipant()
|
||||||
const localCameraTrack = cameraTrack?.track as LocalVideoTrack
|
const localCameraTrack = cameraTrack?.track as LocalVideoTrack
|
||||||
const { saveProcessorSerialized } = usePersistentUserChoices()
|
const { saveProcessorSerialized } = usePersistentUserChoices()
|
||||||
|
const { isEffectsOpen } = useSidePanel()
|
||||||
|
|
||||||
const canPublishCamera = useCanPublishTrack(TrackSource.CAMERA)
|
const canPublishCamera = useCanPublishTrack(TrackSource.CAMERA)
|
||||||
|
|
||||||
|
useRestoreFocus(isEffectsOpen, {
|
||||||
|
resolveTrigger: (activeEl) => {
|
||||||
|
if (activeEl?.tagName === 'DIV') {
|
||||||
|
return document.querySelector<HTMLElement>('#room-options-trigger')
|
||||||
|
}
|
||||||
|
// For direct button clicks, use the active element as is
|
||||||
|
return activeEl
|
||||||
|
},
|
||||||
|
// Focus the first focusable element when the panel opens
|
||||||
|
onOpened: () => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
// Find the first toggle button (blur light button)
|
||||||
|
const firstButton = document.querySelector<HTMLElement>(
|
||||||
|
'[data-attr="toggle-blur-light"]'
|
||||||
|
)
|
||||||
|
if (firstButton) {
|
||||||
|
firstButton.focus({ preventScroll: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
restoreFocusRaf: true,
|
||||||
|
preventScroll: true,
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={css({
|
className={css({
|
||||||
|
|||||||
Reference in New Issue
Block a user