From 8be241350a240724624cb9d39d6e0271af4a77fc Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Tue, 20 Oct 2026 09:30:59 -0700 Subject: [PATCH] fix(mobile): announce failed filter saves beside retry Keep the retained-draft error visible outside scrolling choices and expose it as a live region. Verify semantics and footer visibility at enlarged text; reserve loading retry for unavailable preferences. Co-authored-by: Carl Signed-off-by: Taylor Ho --- .../channels/channels_page/filters.dart | 22 ++++- .../features/channels/channels_page_test.dart | 97 +++++++++++-------- 2 files changed, 73 insertions(+), 46 deletions(-) diff --git a/mobile/lib/features/channels/channels_page/filters.dart b/mobile/lib/features/channels/channels_page/filters.dart index a5f8162604..811bd50230 100644 --- a/mobile/lib/features/channels/channels_page/filters.dart +++ b/mobile/lib/features/channels/channels_page/filters.dart @@ -224,17 +224,15 @@ class _SectionViewSheet extends HookConsumerWidget { const Text( 'Filters are read-only until preferences load from the community.', ), - if (manager?.error != null && !failed.value) + if (manager?.ready != true && + manager?.error != null && + !failed.value) TextButton( onPressed: manager?.busy == true ? null : manager?.refresh, child: const Text('Retry loading preferences'), ), - if (failed.value) - const Text( - 'Could not confirm the filter save. Your choices are kept; try again.', - ), if (custom) ...[ const Divider(), for (final action in { @@ -262,6 +260,20 @@ class _SectionViewSheet extends HookConsumerWidget { ), ), ), + if (failed.value) + Padding( + padding: const EdgeInsets.symmetric( + horizontal: Grid.gutter, + vertical: Grid.xxs, + ), + child: Semantics( + liveRegion: true, + child: Text( + 'Could not confirm the filter save. Your choices are kept; try again.', + style: TextStyle(color: context.colors.error), + ), + ), + ), const SizedBox(height: Grid.xxs), Padding( padding: const EdgeInsets.symmetric(horizontal: Grid.gutter), diff --git a/mobile/test/features/channels/channels_page_test.dart b/mobile/test/features/channels/channels_page_test.dart index 47458ae78e..a93ca41afb 100644 --- a/mobile/test/features/channels/channels_page_test.dart +++ b/mobile/test/features/channels/channels_page_test.dart @@ -295,48 +295,63 @@ void main() { tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - final manager = _filterTestManager(failPublish: true)..ready = true; - await tester.pumpWidget( - buildTestable( - textScaler: const TextScaler.linear(2), - overrides: [ - channelsProvider.overrideWith(() => _FakeNotifier(testChannels)), - channelFilterProvider.overrideWithValue(manager), - ], - ), - ); - await tester.pumpAndSettle(); - await tester.tap(find.byTooltip('Channels options')); - await tester.pumpAndSettle(); - await tester.tap(find.text('Active')); - await tester.pumpAndSettle(); - await tester.ensureVisible(find.text('7 days')); - await tester.tap(find.text('7 days')); - await tester.pumpAndSettle(); - await tester.ensureVisible(find.text('Apply')); - await tester.tap(find.text('Apply')); - await tester.pumpAndSettle(); - expect( - find.text( + final semantics = tester.ensureSemantics(); + try { + final manager = _filterTestManager(failPublish: true)..ready = true; + await tester.pumpWidget( + buildTestable( + textScaler: const TextScaler.linear(2), + overrides: [ + channelsProvider.overrideWith(() => _FakeNotifier(testChannels)), + channelFilterProvider.overrideWithValue(manager), + ], + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byTooltip('Channels options')); + await tester.pumpAndSettle(); + await tester.tap(find.text('Active')); + await tester.pumpAndSettle(); + await tester.ensureVisible(find.text('7 days')); + await tester.tap(find.text('7 days')); + await tester.pumpAndSettle(); + await tester.ensureVisible(find.text('Apply')); + await tester.tap(find.text('Apply')); + await tester.pumpAndSettle(); + expect( + find.text( + 'Could not confirm the filter save. Your choices are kept; try again.', + ), + findsOneWidget, + ); + final failure = find.text( 'Could not confirm the filter save. Your choices are kept; try again.', - ), - findsOneWidget, - ); - final selected = tester.widget( - find.ancestor( - of: find.text('7 days'), - matching: find.byType(AppListRow), - ), - ); - expect(selected.trailing, isA()); - await tester.tap(find.text('Cancel')); - await tester.pumpAndSettle(); - expect(find.byType(AlertDialog), findsNothing); - expect(manager.store.modeFor('channels'), ChannelFilterMode.all); - expect(manager.store.windowFor('channels'), defaultActiveWindowSeconds); - expect(tester.takeException(), isNull); - await tester.pumpWidget(const SizedBox()); - manager.dispose(); + ); + final status = tester.getSemantics(failure); + expect(status.getSemanticsData().flagsCollection.isLiveRegion, isTrue); + final errorRect = tester.getRect(failure); + final footerRect = tester.getRect(find.text('Retry')); + expect(errorRect.top, greaterThanOrEqualTo(0)); + expect(errorRect.bottom, lessThanOrEqualTo(footerRect.top)); + expect(footerRect.bottom, lessThanOrEqualTo(844)); + final selected = tester.widget( + find.ancestor( + of: find.text('7 days'), + matching: find.byType(AppListRow), + ), + ); + expect(selected.trailing, isA()); + await tester.tap(find.text('Cancel')); + await tester.pumpAndSettle(); + expect(find.byType(AlertDialog), findsNothing); + expect(manager.store.modeFor('channels'), ChannelFilterMode.all); + expect(manager.store.windowFor('channels'), defaultActiveWindowSeconds); + expect(tester.takeException(), isNull); + await tester.pumpWidget(const SizedBox()); + manager.dispose(); + } finally { + semantics.dispose(); + } }, );