Open History to see the last commit
1import { useCallback, useState } from "react";
2
3export function useComposerFocusState(isMobileViewport: boolean) {
4 const [isComposerFocused, setIsComposerFocused] = useState(false);
5 const [isComposerScrollCollapsed, setIsComposerScrollCollapsed] = useState(false);
6
7 const restoreAfterTimelineReachedEnd = useCallback(() => {
8 setIsComposerScrollCollapsed(false);
9 // Restore the expanded layout after a timeline control takes focus too.
10 // This state holds the layout open without moving DOM focus to the editor.
11 if (!isMobileViewport) {
12 setIsComposerFocused(true);
13 }
14 }, [isMobileViewport]);
15
16 return {
17 isComposerFocused,
18 setIsComposerFocused,
19 isComposerScrollCollapsed,
20 setIsComposerScrollCollapsed,
21 restoreAfterTimelineReachedEnd,
22 };
23}