@@ -5050,6 +5050,16 @@ window.__ModuleLoader__.load({
50505050 // 上下文裁不住它;运行时拒绝 react-dom 时就地渲染(position:fixed 仍然成立)。
50515051 function MemoryOverlay({ t }) {
50525052 const [open, setOpen] = useOverlayOpen();
5053+ // 库内是否有请求在飞(目前只有「从目录引导」会置位)。Esc / 背板 / ✕ 三条
5054+ // 关闭路径都要看它:关掉弹层会把 MemoryExplorer 连同引导弹层一起卸载,
5055+ // 而 POST 还在飞,回来那句「新建几条、并入几条」就再没有地方显示——
5056+ // 库写进去了,用户却以为没成功(评审 #4453225573)。
5057+ const [explorerBusy, setExplorerBusy] = useState(false);
5058+ // 用 ref 读而不是进 effect 依赖:那个 effect 在 [open] 变化时会
5059+ // closeBtnRef.current.focus(),若把 explorerBusy 也列进依赖,每次请求
5060+ // 起落都会重跑一次并抢焦点——用户正打字输目录时会被踢出输入框。
5061+ const explorerBusyRef = useRef(false);
5062+ useEffect(() => { explorerBusyRef.current = explorerBusy; }, [explorerBusy]);
50535063 // #178:弹层焦点管理——打开时把焦点移入面板(关闭按钮为入口),
50545064 // Tab 循环圈在面板内(Tab 从最后一个元素出去回到关闭按钮),
50555065 // Esc/关闭时把焦点还给触发元素(侧边栏入口)。
@@ -5058,7 +5068,8 @@ window.__ModuleLoader__.load({
50585068 useEffect(() => {
50595069 if (!open) return undefined;
50605070 const onKey = (e) => {
5061- if (e.key === "Escape") { setOpen(false); return; }
5071+ // 库内请求在飞时不响应 Esc:见上面 explorerBusy 的注释。
5072+ if (e.key === "Escape") { if (!explorerBusyRef.current) setOpen(false); return; }
50625073 if (e.key !== "Tab" || !panelRef.current) return;
50635074 const focusables = panelRef.current.querySelectorAll('button, input, select, textarea, a[href], [tabindex]:not([tabindex="-1"])');
50645075 if (focusables.length === 0) return;
@@ -5086,7 +5097,7 @@ window.__ModuleLoader__.load({
50865097 const tree = h(react.Fragment, null,
50875098 h("div", {
50885099 className: "mneme-backdrop",
5089- onClick: () => setOpen(false),
5100+ onClick: () => { if (!explorerBusyRef.current) setOpen(false); } ,
50905101 "aria-hidden": "true"
50915102 }),
50925103 h("div", { className: "mneme-overlay", role: "region", "aria-label": t("memory.view.label"), ref: panelRef },
@@ -5099,12 +5110,15 @@ window.__ModuleLoader__.load({
50995110 type: "button",
51005111 className: "mneme-footbtn",
51015112 ref: closeBtnRef,
5113+ // 忙碌时不禁用、只标 aria-disabled:真的 disabled 会把焦点从按钮上
5114+ // 拿走,而 #178 的 Tab 环靠 closeBtnRef 当入口,焦点落空就出不去。
5115+ "aria-disabled": String(explorerBusy),
51025116 "aria-label": t("memory.overlay.close"),
51035117 title: t("memory.overlay.close"),
5104- onClick: () => setOpen(false)
5118+ onClick: () => { if (!explorerBusyRef.current) setOpen(false); }
51055119 }, "✕")
51065120 ),
5107- h("div", { className: "mneme-overlaybody" }, h(MemoryExplorer, { t }))
5121+ h("div", { className: "mneme-overlaybody" }, h(MemoryExplorer, { t, onBusyChange: setExplorerBusy }))
51085122 )
51095123 );
51105124 if (reactDom && typeof document !== "undefined") return reactDom.createPortal(tree, document.body);
@@ -7669,7 +7683,7 @@ window.__ModuleLoader__.load({
76697683 );
76707684 }
76717685
7672- function MemoryExplorer({ t }) {
7686+ function MemoryExplorer({ t, onBusyChange }) {
76737687 const [view, setView] = useState("memory"); // memory | entity | status | settings
76747688 const [items, setItems] = useState([]); // loaded browse pages, chrono desc
76757689 const [total, setTotal] = useState(0); // server count for the current type filter
@@ -7708,6 +7722,18 @@ window.__ModuleLoader__.load({
77087722 const [bootstrapOpen, setBootstrapOpen] = useState(false);
77097723 // 引导请求是否在飞:「⋯」按钮在忙碌时必须不关弹层(评审 #4452245292)。
77107724 const [bootstrapBusy, setBootstrapBusy] = useState(false);
7725+ // 一路直接抬到外层 MemoryOverlay:它要在 Esc / 背板 / ✕ 三条关闭路径上一起挡
7726+ // (评审 #4453225573)。刻意**不**用 useEffect 转报——那要等渲染提交后才跑,
7727+ // 中间那一拍外层守卫读到的是 false,正是 #4452539705 那条的老毛病。
7728+ // 走 BootstrapDialog 的回调,它的 submit 里是同步调的。
7729+ // better-sidebar 那个 tab 注册时不传 onBusyChange,所以这里必须容忍 undefined。
7730+ // 身份必须稳定:BootstrapDialog 的卸载 effect 依赖 [onBusyChange],父组件每
7731+ // 重渲染一次就会先跑 cleanup 调 onBusyChange(false)——而父组件恰好是在
7732+ // setBootstrapBusy(true) 之后重渲染的,那一抹等于把刚置上的忙碌标记当场抹掉。
7733+ const reportBootstrapBusy = useCallback((v) => {
7734+ setBootstrapBusy(v);
7735+ if (onBusyChange) onBusyChange(v);
7736+ }, [onBusyChange]);
77117737 const [createOpen, setCreateOpen] = useState(false);
77127738 const [shareOpen, setShareOpen] = useState(false);
77137739 const [receiveOpen, setReceiveOpen] = useState(false);
@@ -8064,6 +8090,13 @@ window.__ModuleLoader__.load({
80648090 "aria-label": t("memory.explorer.more"),
80658091 "aria-expanded": String(menuOpen),
80668092 title: t("memory.explorer.more"),
8093+ // 引导请求在飞时整个「⋯」都不给开:菜单与引导弹层共用同一个
8094+ // 绝对定位锚点、同一层 z-index,弹层排在菜单之后渲染,会把
8095+ // 菜单顶上的两项导出盖住——它们没有 disabled,却点不到
8096+ // (评审 #4453225585)。不开菜单,就不存在「可点但被遮住」。
8097+ // 这也顺带把 #4452245292 那条锁得更死:菜单开不了,就没有
8098+ // 任何路径能在请求中途把引导弹层卸掉。
8099+ disabled: bootstrapBusy,
80678100 onClick: () => {
80688101 setMenuOpen(!menuOpen);
80698102 setImportOpen(false);
@@ -8102,7 +8135,7 @@ window.__ModuleLoader__.load({
81028135 bootstrapOpen && h(BootstrapDialog, {
81038136 t,
81048137 onClose: () => setBootstrapOpen(false),
8105- onBusyChange: setBootstrapBusy ,
8138+ onBusyChange: reportBootstrapBusy ,
81068139 onImported: () => setReloadKey((k) => k + 1)
81078140 }),
81088141 shareOpen && h(ShareDialog, { t, onClose: () => setShareOpen(false) }),
0 commit comments