Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

useComposerFocusState.ts

20 lines633 Bytes

1import { useCallback, useState } from "react";
2​
3export function useComposerFocusState() {
4 const [isComposerFocused, setIsComposerFocused] = useState(false);
5 const [isComposerScrollCollapsed, setIsComposerScrollCollapsed] = useState(false);
6​
7 // Reaching the end of the timeline lifts a scroll collapse without moving
8 // DOM focus to the editor.
9 const restoreAfterTimelineReachedEnd = useCallback(() => {
10 setIsComposerScrollCollapsed(false);
11 }, []);
12​
13 return {
14 isComposerFocused,
15 setIsComposerFocused,
16 isComposerScrollCollapsed,
17 setIsComposerScrollCollapsed,
18 restoreAfterTimelineReachedEnd,
19 };