a tool for shared writing and social publishing

reverted the last change and redid it in a not stupid way

+12 -3
-3
components/Blocks/Block.tsx
··· 88 88 89 89 let [areYouSure, setAreYouSure] = useState(false); 90 90 useEffect(() => { 91 - if (selected && rep) { 92 - focusPage(props.parent, rep); 93 - } 94 91 if (!selected) { 95 92 setAreYouSure(false); 96 93 }
+12
components/Blocks/useBlockMouseHandlers.ts
··· 8 8 import { getBlocksWithType } from "src/hooks/queries/useBlocks"; 9 9 import { focusBlock } from "src/utils/focusBlock"; 10 10 import { useIsMobile } from "src/hooks/isMobile"; 11 + import { scrollIntoViewIfNeeded } from "src/utils/scrollIntoViewIfNeeded"; 12 + import { elementId } from "src/utils/elementId"; 11 13 12 14 let debounce: number | null = null; 13 15 export function useBlockMouseHandlers(props: Block) { ··· 39 41 parent: props.parent, 40 42 }); 41 43 useUIState.getState().setSelectedBlock(props); 44 + 45 + // scroll to the page containing the block, if offscreen 46 + let parentPage = elementId.page(props.parent).container; 47 + setTimeout(() => { 48 + scrollIntoViewIfNeeded( 49 + document.getElementById(parentPage), 50 + false, 51 + "smooth", 52 + ); 53 + }, 50); 42 54 } 43 55 }, 44 56 [props, entity_set.permissions.write, isMobile],