Skip to content

Commit 58e5750

Browse files
authored
Persistent BottomSheet are not dismissible via a11y (#107435)
1 parent 4ef6b81 commit 58e5750

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

packages/flutter/lib/src/material/scaffold.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
21822182
),
21832183
);
21842184
},
2185-
true,
2185+
isPersistent: true,
21862186
animationController: animationController,
21872187
);
21882188
}
@@ -2225,8 +2225,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
22252225
}
22262226

22272227
PersistentBottomSheetController<T> _buildBottomSheet<T>(
2228-
WidgetBuilder builder,
2229-
bool isPersistent, {
2228+
WidgetBuilder builder, {
2229+
required bool isPersistent,
22302230
required AnimationController animationController,
22312231
Color? backgroundColor,
22322232
double? elevation,
@@ -2412,7 +2412,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
24122412
setState(() {
24132413
_currentBottomSheet = _buildBottomSheet<T>(
24142414
builder,
2415-
false,
2415+
isPersistent: false,
24162416
animationController: controller,
24172417
backgroundColor: backgroundColor,
24182418
elevation: elevation,
@@ -3165,7 +3165,7 @@ class _StandardBottomSheetState extends State<_StandardBottomSheet> {
31653165
},
31663166
child: Semantics(
31673167
container: true,
3168-
onDismiss: close,
3168+
onDismiss: !widget.isPersistent ? close : null,
31693169
child: NotificationListener<DraggableScrollableNotification>(
31703170
onNotification: extentChanged,
31713171
child: BottomSheet(

packages/flutter/test/material/scaffold_test.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,28 @@ void main() {
25992599
final ErrorSummary summary = error.diagnostics.first as ErrorSummary;
26002600
expect(summary.toString(), 'The showSnackBar() method cannot be called during build.');
26012601
});
2602+
2603+
testWidgets('Persistent BottomSheet is not dismissible via a11y means', (WidgetTester tester) async {
2604+
final Key bottomSheetKey = UniqueKey();
2605+
2606+
await tester.pumpWidget(MaterialApp(
2607+
home: Scaffold(
2608+
bottomSheet: Container(
2609+
key: bottomSheetKey,
2610+
height: 44,
2611+
color: Colors.blue,
2612+
child: const Text('BottomSheet'),
2613+
),
2614+
),
2615+
));
2616+
2617+
expect(
2618+
tester.getSemantics(find.byKey(bottomSheetKey)),
2619+
// Having the redundant argument value makes the intent of the test clear.
2620+
// ignore: avoid_redundant_argument_values
2621+
matchesSemantics(label: 'BottomSheet', hasDismissAction: false),
2622+
);
2623+
});
26022624
}
26032625

26042626
class _GeometryListener extends StatefulWidget {

0 commit comments

Comments
 (0)