Show the current page in the browser tab title

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 5.5 committed 2026-10-01 14:09:06 -04:00
1 parent d13f55faf7
commit b4f038b185
2 files changed
+28

No files matched your search

+12
View File
@@ -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$/));
});
});
+16
View File
@@ -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,