11import discourseConfigRef from "~/utils/discourseConfigRef" ;
2- import React , { useCallback , useEffect , useMemo , useState } from "react" ;
2+ import React , {
3+ useCallback ,
4+ useEffect ,
5+ useMemo ,
6+ useRef ,
7+ useState ,
8+ } from "react" ;
39import AutocompleteInput from "roamjs-components/components/AutocompleteInput" ;
410import getAllPageNames from "roamjs-components/queries/getAllPageNames" ;
511import {
@@ -11,6 +17,7 @@ import {
1117} from "@blueprintjs/core" ;
1218import createBlock from "roamjs-components/writes/createBlock" ;
1319import deleteBlock from "roamjs-components/writes/deleteBlock" ;
20+ import updateBlock from "roamjs-components/writes/updateBlock" ;
1421import type { RoamBasicNode } from "roamjs-components/types" ;
1522import NumberPanel from "roamjs-components/components/ConfigPanels/NumberPanel" ;
1623import TextPanel from "roamjs-components/components/ConfigPanels/TextPanel" ;
@@ -523,6 +530,7 @@ const LeftSidebarPersonalSectionsContent = ({
523530 const [ settingsDialogSectionUid , setSettingsDialogSectionUid ] = useState <
524531 string | null
525532 > ( null ) ;
533+ const sectionTitleUpdateTimeoutRef = useRef < ReturnType < typeof setTimeout > > ( ) ;
526534
527535 useEffect ( ( ) => {
528536 const initialize = async ( ) => {
@@ -633,7 +641,6 @@ const LeftSidebarPersonalSectionsContent = ({
633641 if ( ! personalSectionUid ) {
634642 return null ;
635643 }
636-
637644 return (
638645 < div className = "flex flex-col gap-4 p-1" >
639646 < div className = "mb-2" >
@@ -692,6 +699,36 @@ const LeftSidebarPersonalSectionsContent = ({
692699 >
693700 < div className = "space-y-4 p-4" >
694701 < div className = "space-y-3" >
702+ < div >
703+ < label className = "mb-1 flex items-center text-sm font-medium" >
704+ Section Title
705+ < span
706+ className = "bp3-icon bp3-icon-info-sign ml-1"
707+ title = "Display name for this section"
708+ />
709+ </ label >
710+ < InputGroup
711+ value = { activeDialogSection . text }
712+ onChange = { ( e ) => {
713+ const nextValue = e . target . value ;
714+ const sectionUid = activeDialogSection . uid ;
715+ setSections ( ( prev ) =>
716+ prev . map ( ( s ) =>
717+ s . uid === sectionUid ? { ...s , text : nextValue } : s ,
718+ ) ,
719+ ) ;
720+ clearTimeout ( sectionTitleUpdateTimeoutRef . current ) ;
721+ sectionTitleUpdateTimeoutRef . current = setTimeout ( ( ) => {
722+ void updateBlock ( {
723+ uid : sectionUid ,
724+ text : nextValue ,
725+ } ) . then ( ( ) => {
726+ refreshAndNotify ( ) ;
727+ } ) ;
728+ } , 300 ) ;
729+ } }
730+ />
731+ </ div >
695732 < NumberPanel
696733 title = "Truncate-result?"
697734 description = "Maximum characters to display"
0 commit comments