From b4f038b185502ff954e8b670f7f14fdb5b96676a Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Thu, 1 Oct 2026 14:09:06 -0400 Subject: [PATCH] Show the current page in the browser tab title Co-Authored-By: Claude Sonnet 5.5 --- src/App.flow.test.jsx | 12 ++++++++++++ src/App.jsx | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/App.flow.test.jsx b/src/App.flow.test.jsx index 66f97b8..84feff8 100644 --- a/src/App.flow.test.jsx +++ b/src/App.flow.test.jsx @@ -235,3 +235,15 @@ describe('Study cards on Home', () => { expect(screen.queryByText('F', { selector: 'span' })).not.toBeInTheDocument(); // only in the Tag filter }); }); + +describe('Window title', () => { + test('names the page you are on, including the chapter in the reader', async () => { + const user = userEvent.setup(); + await renderApp(); + expect(document.title).toBe('My Studies · Bible Study'); + await user.click(screen.getByRole('button', { name: /reading plans/i })); + await waitFor(() => expect(document.title).toBe('Reading Plans · Bible Study')); + await user.click(screen.getByRole('button', { name: /read bible/i })); + await waitFor(() => expect(document.title).toMatch(/^[A-Za-z0-9 ]+ \d+ · Bible Study$/)); + }); +}); diff --git a/src/App.jsx b/src/App.jsx index b89a8e4..50d715d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -128,6 +128,22 @@ const AppInner = () => { return () => window.removeEventListener('keydown', onKey); }, []); + // The browser tab and history show where you are ("Romans 8 · Bible Study", "Luke — Outline · Bible Study") + useEffect(() => { + const names = { + home: 'My Studies', setup: 'Chunks', study: 'Study', outline: 'Outline', script: 'Script', export: 'Export', + import: 'Import', pronunciation: 'Pronunciation Guide', settings: 'Settings', admin: 'Admin', 'reading-plans': 'Reading Plans', + }; + let page = names[currentPage] ?? ''; + if (currentPage === 'reader') { + const book = bookOptions.find((b) => b.abbrev === reader.readerBookAbbrev)?.name ?? ''; + page = `${book} ${reader.readerChapter}`.trim(); + } else if (project?.title && ['setup', 'study', 'outline', 'script', 'export', 'pronunciation'].includes(currentPage)) { + page = `${project.title} — ${page}`; + } + document.title = page ? `${page} · Bible Study` : 'Bible Study'; + }, [currentPage, project?.title, reader.readerBookAbbrev, reader.readerChapter]); + // Back/Forward move between pages instead of leaving the app. (Not for ?share= links: that page is separate.) useHistoryNav({ page: currentPage,