Skip to content

Keep the page title when a Flutter island starts - #78

Merged
KamilSztandur merged 3 commits into
mainfrom
keep-page-title
Sep 8, 2026
Merged

KamilSztandur merged 3 commits into
mainfrom
keep-page-title

Conversation

@KamilSztandur

Copy link
Copy Markdown
Collaborator

The browser tab showed the site's address instead of the page title — on the landing page and on every docs page with a live example.

Cause: every island is a MaterialApp, and MaterialApp renders a Title widget with an empty title. The Flutter web engine forwards that to document.title, so the moment a demo attaches, the title becomes "" and browsers fall back to the URL.

Fix: both runtimes (docs_app/lib/flutter-examples/runtime.ts, landing/web/landing.js) install a small guard on document.title before the engine loads: writes of an empty string are ignored, everything else goes through, so the titles Next sets on client-side navigation still work.

Verified in headless Chrome:

Page Before island After island
/ advanced_forms — Form validation and state for Flutter unchanged
/docs/first-form Your first form — advanced_forms unchanged
client-side nav → /docs/installation → /docs/focus (with island) Installation — advanced_forms → Focus — advanced_forms

🤖 Generated with Claude Code

Every island is a MaterialApp, and MaterialApp renders a Title widget
with an empty title; the web engine forwards that to document.title, so
the tab showed the address instead of the page title as soon as a demo
attached — on the landing page and on every docs page with an example.

Both runtimes now ignore writes of an empty document.title before the
engine loads; the titles Next sets on navigation still go through.
Verified in headless Chrome on /, /docs/first-form and across client-
side navigation between docs pages.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread docs_app/lib/flutter-examples/runtime.ts Outdated
MaterialApp's title defaults to '', and with any non-null title
WidgetsApp mounts a Title widget whose value the web engine writes into
document.title. With title: null, WidgetsApp skips Title on the web —
the host page owns the title (flutter/flutter#152003). The JS guards on
document.title from the previous commit are gone.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread docs_app/flutter/lib/support/island_frame.dart Outdated
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@KamilSztandur
KamilSztandur merged commit 65c175e into main Sep 8, 2026
4 checks passed
@KamilSztandur
KamilSztandur deleted the keep-page-title branch September 8, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants