carp-dk / carp-dk/research.package

RPUITask's onCancel does not respect RPOrderedTask's closeAfterFinished flag, as onSubmit does

Open
#149 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
52
Forks
47
Avg merge
5h 35m
Merged PRs (30d)
4

Description

When the user confirms cancelling the task (`showCancelConfirmationDialog`), the navigator is
popped twice to close the cancel confirmation dialog and exit the task.

The task should only be exited if the `closeAfterFinished` is true, but is done unconditionally.

See line `Navigator.of(context).pop(); // BUG <- should be called conditionally` below.

Am I right, or is this the intended behavior? I am going to investigate it on my fork and will report back.

```dart
void showCancelConfirmationDialog() {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text(widget.task.isConsentTask
? RPLocalizations.of(context)?.translate('cancel_confirmation') ??
"Cancel?"
: RPLocalizations.of(context)
?.translate('discard_confirmation') ??
"Discard results and quit?"),
actions: [
ButtonTheme(
minWidth: 70,
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
(CupertinoTheme.of(context).primaryColor ==
CupertinoColors.activeBlue)
? Theme.of(context).primaryColor
: CupertinoTheme.of(context).primaryColor),
),
child: Text(
RPLocalizations.of(context)?.translate('NO') ?? "NO",
style: const TextStyle(color: Colors.white),
),
onPressed: () =>
Navigator.of(context).pop(), // Dismissing the pop-up
),
),
OutlinedButton(
child: Text(
RPLocalizations.of(context)?.translate('YES') ?? "YES",
style: TextStyle(
color: ((CupertinoTheme.of(context).primaryColor ==
CupertinoColors.activeBlue)
? Theme.of(context).primaryColor
: CupertinoTheme.of(context).primaryColor)),
),
onPressed: () {
// Calling the onCancel method with which the developer can for
// e.g. save the result on the device.
// Only call it if it's not null
widget.onCancel?.call(_taskResult);
// Popup dismiss
Navigator.of(context).pop();
// Exit the Ordered Task
Navigator.of(context).pop(); // BUG <- should be called conditionally
},
)
],
);
},
);
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at RPUITask's showCancelConfirmationDialog and compare its cancellation flow with RPOrderedTask's onSubmit handling of closeAfterFinished. Confirm the intended behavior for the Navigator calls and whether the task should exit only when that flag is true. Done means the confirmation dialog is dismissed, onCancel still runs, and task exit matches closeAfterFinished.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.