[iOS] SnackBars on iOS show unusable and unnecessary Voice Control tag
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- accessibility, mobile
Research direction
Start with packages/flutter/lib/src/material/snack_bar.dart, specifically _SnackBarState.build and the Semantics node shown in the issue. Check how dismissDirection relates to the onDismiss action, then look for or add a regression test covering Voice Control semantics for a SnackBar. Done when the unusable extra Voice Control tag is absent while the close button remains usable.
Written by the indexing model from the issue text.
Description
Steps to reproduce
- Create an app with a SnackBar and open it on an iOS device.
- Enable Voice Control (https://support.apple.com/en-us/111778)
- View the SnackBar
Expected results
The SnackBar should have just one Voice Control tag, which can be used to close the snackbar.
Actual results
As seen in the image above, the SnackBar actually has two voice control tags. Tag '1' triggers no action, and it also should not be on the SnackBar. Tag '2' on the 'X' button is expected.
I suspect this is because in packages/flutter/lib/src/material/snack_bar.dart inside _SnackBarState.build, the Semantics node unconditionally assigns an onDismiss action for swipe-to-dismiss behavior on SnackBars, and Voice Control is adding a tag for this. However, this doesn't actually do anything since Voice Control performs a tap, not a swipe.
snackBar = Semantics(
container: true,
liveRegion: true,
onDismiss: () {
ScaffoldMessenger.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.dismiss);
},
child: Dismissible(
// ...
direction: dismissDirection,
child: snackBar,
),
);
One potential fix would be omitting the onDismiss semantic action if dismissDirection is DismissDirection.none (I tried this locally and this seemed to fix the issue)
snackBar = Semantics(
container: true,
liveRegion: true,
onDismiss: dismissDirection == DismissDirection.none
? null
: () {
ScaffoldMessenger.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.dismiss);
},
// ...
Code sample
import 'package:flutter/material.dart';
final messengerKey = GlobalKey<ScaffoldMessengerState>();
void main() {
runApp(MaterialApp(
scaffoldMessengerKey: messengerKey,
home: const Scaffold(),
));
WidgetsBinding.instance.addPostFrameCallback((_) {
messengerKey.currentState?.showSnackBar(
SnackBar(
behavior: SnackBarBehavior.fixed,
dismissDirection: DismissDirection.down,
content: const Text('Text'),
action: SnackBarAction(label: 'X', onPressed: () {}),
duration: const Duration(days: 365),
),
);
});
}
Screenshots or Video
See screenshot in "Actual results" section.
Logs
No response
Flutter Doctor output
N/A
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 33.2k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 407
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from flutter/flutter
-
Difficulty 1/5 Under an hour Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
P2 platform-ios platform-macos team-ios tool triaged-ios
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
[pigeon] Stop binding HostApi interfaces with jnigen: they're unused and make up 35% of the `.jni.dart` filePossibly taken @tarrinneal claimed this 2 days ago. Openp: pigeon P2 package team-ecosystem triaged-ecosystem
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
flutter/flutter#193882 · 1 assignee ·
Maintainers usually reply within 1 day
-
[pigeon] Swift FFI (`swift_use_ffi`) generates code that doesn't compile for files with event channels or ProxyApisPossibly taken @tarrinneal claimed this 2 days ago. Openp: pigeon P2 package team-ecosystem triaged-ecosystem
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
flutter/flutter#193881 · 1 assignee ·
Maintainers usually reply within 1 day
-
BorderSide.scale resets non-default strokeAlignPossibly taken @kaluli123123 claimed this 2 days ago. Opena: tests framework has reproducible steps team-framework
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
flutter/flutter#193758 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bggRGjQaUbCoE/PiliPlus#3235 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
intel/rohd-wave-viewer#11 ·
-
DOCS UPDATE: README.md and BACKEND.md reference a search-meetings edge function that does not existOpendocumentation
Difficulty 1/5 1-3 hours Newbie friendliness 93/100
AOSSIE-Org/Ell-ena#337 ·
-
cat: puzzle
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
lichess-org/mobile#3826 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
saber-notes/saber#1844 ·