vomebook commited on
Commit
ee3d554
·
verified ·
1 Parent(s): 122c37b

fix(reader): keep TOC panel open after hint

Browse files
Files changed (1) hide show
  1. static/reader/ui/reader-toc.mjs +2 -21
static/reader/ui/reader-toc.mjs CHANGED
@@ -180,13 +180,10 @@ export function createReaderToc(readerContext) {
180
  }
181
 
182
  let tocHintShown = false, tocHintPending = false, tocHintTimer = 0;
183
- let tocHintInteractionCleanup = null;
184
  const cancelTocHint = () => {
185
  clearTimeout(tocHintTimer);
186
  tocHintTimer = 0;
187
  tocHintPending = false;
188
- tocHintInteractionCleanup?.();
189
- tocHintInteractionCleanup = null;
190
  };
191
  const finishTocHint = () => {
192
  tocHintTimer = 0;
@@ -201,7 +198,6 @@ export function createReaderToc(readerContext) {
201
  const panel = document.querySelector("#history-panel");
202
  if (!panel) return;
203
  tocHintShown = true;
204
- const autoSerial = readerContext.readerPanelInteractionSerial;
205
  // This is a visual hint, not a user-opened panel state. Keep the toolbar's
206
  // aria-expanded/state closed so the next history-button click converts the
207
  // hint into a normal persistent panel instead of immediately closing it.
@@ -210,23 +206,8 @@ export function createReaderToc(readerContext) {
210
  panel.classList.add("is-open");
211
  readerContext.selectPanel("toc");
212
  readerContext.updateTocCurrentMark();
213
- const markInteraction = () => { readerContext.readerPanelInteractionSerial++; };
214
- const events = ["pointerdown", "keydown", "focusin"];
215
- events.forEach(type => panel.addEventListener(type, markInteraction, true));
216
- tocHintInteractionCleanup = () => {
217
- events.forEach(type => panel.removeEventListener(type, markInteraction, true));
218
- tocHintInteractionCleanup = null;
219
- };
220
- tocHintTimer = setTimeout(() => {
221
- tocHintInteractionCleanup?.();
222
- tocHintTimer = 0;
223
- if (!readerContext.readerLifecycle.disposed && !readerContext.panelState.open &&
224
- panel.classList.contains("is-open") &&
225
- readerContext.readerPanelInteractionSerial === autoSerial)
226
- panel.classList.remove("is-open");
227
- if (!panel.classList.contains("is-open"))
228
- setTimeout(() => { if (!panel.classList.contains("is-open")) panel.hidden = true; }, 250);
229
- }, 650);
230
  };
231
  let phaseCleanup = null;
232
  function ensureTocHintPhaseListener() {
 
180
  }
181
 
182
  let tocHintShown = false, tocHintPending = false, tocHintTimer = 0;
 
183
  const cancelTocHint = () => {
184
  clearTimeout(tocHintTimer);
185
  tocHintTimer = 0;
186
  tocHintPending = false;
 
 
187
  };
188
  const finishTocHint = () => {
189
  tocHintTimer = 0;
 
198
  const panel = document.querySelector("#history-panel");
199
  if (!panel) return;
200
  tocHintShown = true;
 
201
  // This is a visual hint, not a user-opened panel state. Keep the toolbar's
202
  // aria-expanded/state closed so the next history-button click converts the
203
  // hint into a normal persistent panel instead of immediately closing it.
 
206
  panel.classList.add("is-open");
207
  readerContext.selectPanel("toc");
208
  readerContext.updateTocCurrentMark();
209
+ // Keep the directory visible. The toolbar button can still convert this
210
+ // visual hint into normal panel state on the user's first interaction.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  };
212
  let phaseCleanup = null;
213
  function ensureTocHintPhaseListener() {