Web: an announcement made while a modal dialog is open silences every later SemanticsService announcement on the page
Summary
On Flet 1.0.1 (web), when Flutter makes an accessibility announcement while a modal dialog is open (for example the
"N characters remaining" counter of a TextField with max_length), the page's <flt-announcement-polite> element is
moved into the dialog's <flt-semantics> node. Closing the dialog removes that node, and with it the announcement
element. After that, no SemanticsService.announce_message call is heard again until the page is reloaded.
The same dialog without max_length leaves <flt-announcement-host> intact, and later announcements are heard.
Steps to reproduce
import flet as ft
async def main(page: ft.Page) -> None:
def announce(e: ft.Event) -> None:
svc = next((s for s in page.services if isinstance(s, ft.SemanticsService)), None) or ft.SemanticsService()
page.run_task(svc.announce_message, "Hello from the page")
def dialog(with_counter: bool) -> ft.AlertDialog:
return ft.AlertDialog(modal=True, title=ft.Text("Enter code"),
content=ft.TextField(label="Code", max_length=6 if with_counter else None),
actions=[ft.TextButton(content=ft.Text("Close"), on_click=lambda e: page.pop_dialog())])
page.add(ft.Column([
ft.Button(content=ft.Text("Announce"), on_click=announce),
ft.Button(content=ft.Text("Open dialog"), on_click=lambda e: page.show_dialog(dialog(True))),
ft.Button(content=ft.Text("Open dialog (no counter)"), on_click=lambda e: page.show_dialog(dialog(False))),
]))
ft.run(main, view=ft.AppView.WEB_BROWSER, port=8700, host="127.0.0.1")Open http://127.0.0.1:8700 in Chrome with a screen reader (or the accessibility tree / DOM inspector open), then:
- Click Announce. It is heard: the text lands in
<flt-announcement-polite>inside<flt-announcement-host>. - Click Open dialog, type 3 digits into the field (Flutter announces "N characters remaining"), then click Close.
- Click Announce again.
Expected
Step 3 is announced, as in step 1.
Actual
Step 3 is not announced. While the dialog was open, <flt-announcement-polite> was re-parented into the dialog's
<flt-semantics> node, and it was removed with that node when the dialog closed. Nothing is announced again on that
page until a reload.
Control: repeating step 2 with Open dialog (no counter) leaves the announcement host in place, and step 3 is heard.
Measured
Headless Chromium at 390×844. "Heard" means the text reached an attached flt-announcement-* element, polled every
50 ms. With the counter: the announcement before the dialog was heard and the one after it was not. Without the counter:
both were heard.
Environment
- Flet 1.0.1, web (server mode, stock web client)
- Chromium (Playwright), macOS
Not yet established
Whether this is in Flutter's web engine or in Flet's web client. The deciding test is the same three steps in a plain
Flutter web app (SemanticsService.announce, a TextField(maxLength: 6) inside showDialog), and it has not been run.
If it reproduces there, this belongs upstream in flutter/flutter.
Source: flet-dev/flet