Skip to content

Commit

Permalink
fix: update browser tab title on notebook rename, prioritize app title.
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnis committed May 28, 2024
1 parent d1debeb commit a8d10bb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
18 changes: 8 additions & 10 deletions examples/dashboards/movies.py → examples/dashboards/movies350.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import marimo

__generated_with = "0.1.33"
app = marimo.App(width="full")
__generated_with = "0.6.10"
app = marimo.App(width="full", app_title="Movies_Neat")


@app.cell
Expand Down Expand Up @@ -57,14 +57,12 @@ def handle_click(v):
return button_00s, button_10s, button_80s, button_90s, decade_button


@app.cell
def __(mo, previous_end_date, previous_start_date):
mo.md(
f"""
> Compared to: {previous_start_date.strftime("%Y-%m-%d")} - {previous_end_date.strftime("%Y-%m-%d")}
"""
)
return
app._unparsable_cell(
r"""
mo.md(f\"> Compared to: {previous_start_date.strftime(\\"%Y-%m-%d\\")} - {previous_end_date.strftime(\\"%Y-%m-%d\\")}\")
""",
name="__"
)


@app.cell
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/core/edit-app.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* Copyright 2024 Marimo. All rights reserved. */
import { useCallback, useEffect, useState } from "react";

import {
sendComponentValues,
sendInterrupt,
sendRename,
sendSave,
} from "@/core/network/requests";

import { Controls } from "@/components/editor/controls/Controls";
import { FilenameInput } from "@/components/editor/header/filename-input";
import { FilenameForm } from "@/components/editor/header/filename-form";
Expand Down Expand Up @@ -118,7 +116,8 @@ export const EditApp: React.FC<AppProps> = ({ userConfig, appConfig }) => {
return sendRename(name)
.then(() => {
setFilename(name);
document.title = name || "Untitled Notebook"; // Assign a default title if name is null
// 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 @@ -127,10 +126,11 @@ export const EditApp: React.FC<AppProps> = ({ userConfig, appConfig }) => {
});
});

// Update document title whenever filename changes
// Update document title whenever filename or app_title changes
useEffect(() => {
document.title = filename || "Untitled Notebook"; // Assign a default title if filename is null
}, [filename]);
// 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);
Expand Down
5 changes: 3 additions & 2 deletions marimo/_tutorials/plots.py → marimo/_tutorials/plots1.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright 2024 Marimo. All rights reserved.

import marimo

__generated_with = "0.1.69"
app = marimo.App()
__generated_with = "0.6.10"
app = marimo.App(app_title="plots99")


@app.cell(hide_code=True)
Expand Down

0 comments on commit a8d10bb

Please sign in to comment.