Update the document title to include the document name. (#3197)

We now update the `document.title` with the document name. For empty
rooms we default back to `tldraw`, just as we have it in `index.html`.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [ ] `sdk` — Changes the tldraw SDK
- [x] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [x] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know

### Release Notes

- Use the document name in the `document.title`.
pull/3201/head
Mitja Bezenšek 2024-03-18 16:34:08 +01:00 zatwierdzone przez GitHub
rodzic 16a28bfd90
commit d16e06ff40
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -239,6 +239,14 @@ const DocumentNameEditor = track(function DocumentNameEditor({
}
}, [documentSettings.name, editor, state.isEditing, state.name, setState])
useEffect(() => {
if (documentSettings.name) {
document.title = `${documentSettings.name} · tldraw`
} else {
document.title = 'tldraw'
}
}, [documentSettings.name])
const handleChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
const value = e.currentTarget.value