Skip to content

Commit

Permalink
Fix #1428 - Update Browser Tab Title When Notebook is Renamed (#1496)
Browse files Browse the repository at this point in the history
* Updates to edit-app.tsx to resolve #1428

* fix: update browser tab title on notebook rename, prioritize app title. Fixes #1428

---------

Co-authored-by: victg <123119434+statistron@users.noreply.github.com>
  • Loading branch information
vrtnis and vrtnis committed May 28, 2024
1 parent 3c3a434 commit 692b777
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/core/edit-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ export const EditApp: React.FC<AppProps> = ({ userConfig, appConfig }) => {
}
});

return sendRename(name)
return sendRename(name)
.then(() => {
setFilename(name);
// Set document title: app_title takes precedence, then filename, then default
document.title = appConfig.app_title || name || "Untitled Notebook";
return name;
})
.catch((error) => {
Expand All @@ -126,6 +128,12 @@ export const EditApp: React.FC<AppProps> = ({ userConfig, appConfig }) => {
});
});

// Update document title whenever filename or app_title changes
useEffect(() => {
// Set document title: app_title takes precedence, then filename, then default
document.title = appConfig.app_title || filename || "Untitled Notebook";
}, [appConfig.app_title, filename]);

const cells = notebookCells(notebook);
const cellIds = cells.map((cell) => cell.id);
const codes = cells.map((cell) => cell.code);
Expand Down

0 comments on commit 692b777

Please sign in to comment.