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

composerSelectionHold.ts

15 lines627 Bytes

1/**
2 * Whether a live text selection inside the timeline should hold the composer
3 * open. A drag-select in the conversation blurs the composer, and letting it
4 * rest mid-gesture reflows the timeline, which dismisses the selection
5 * toolbar the user was about to use.
6 */
7export function selectionHoldsComposerOpen(
8 selection: Pick<Selection, "isCollapsed" | "rangeCount" | "getRangeAt"> | null,
9 timeline: Node | null,
10): boolean {
11 if (!timeline || !selection || selection.isCollapsed || selection.rangeCount === 0) {
12 return false;
13 }
14 return timeline.contains(selection.getRangeAt(0).commonAncestorContainer);