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`.
This commit is contained in:
Mitja Bezenšek 2024-03-18 16:34:08 +01:00 committed by GitHub
parent 16a28bfd90
commit d16e06ff40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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