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 <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
Taylor Ho
2026-10-20 09:30:59 -07:00
parent 2698bd456d
commit 8be241350a
2 changed files with 73 additions and 46 deletions

View File

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

View File

@@ -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<AppListRow>(
find.ancestor(
of: find.text('7 days'),
matching: find.byType(AppListRow),
),
);
expect(selected.trailing, isA<Icon>());
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<AppListRow>(
find.ancestor(
of: find.text('7 days'),
matching: find.byType(AppListRow),
),
);
expect(selected.trailing, isA<Icon>());
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();
}
},
);