Skip to content

Commit

Permalink
fix: [MDS-1008] Fix open modal giving error on Storybook navigation (#…
Browse files Browse the repository at this point in the history
…367)

Co-authored-by: Birgitt Majas <birgitt.majas@yolo.com>
  • Loading branch information
GittHub-d and Birgitt Majas committed Feb 26, 2024
1 parent 5c58366 commit 170173a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
4 changes: 4 additions & 0 deletions example/lib/src/storybook/routing/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ GoRouter router = GoRouter(
pageBuilder: (BuildContext context, GoRouterState state) => const NoTransitionPage(
child: ModalStory(),
),
onExit: (BuildContext _) {
if (router.canPop()) router.pop();
return true;
},
),
GoRoute(
path: PopoverStory.path,
Expand Down
24 changes: 8 additions & 16 deletions example/lib/src/storybook/stories/modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ModalStory extends StatelessWidget {
context: context,
useRootNavigator: false,
barrierColor: barrierColor,
builder: (BuildContext _) {
builder: (BuildContext context) {
return Directionality(
textDirection: Directionality.of(context),
child: MoonModal(
Expand Down Expand Up @@ -104,21 +104,13 @@ class ModalStory extends StatelessWidget {
}

return Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 64.0, horizontal: 16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Builder(
builder: (BuildContext context) {
return MoonFilledButton(
label: const Text("Tap me"),
onTap: () => modalBuilder(context),
);
},
),
],
),
child: Builder(
builder: (BuildContext context) {
return MoonFilledButton(
label: const Text("Tap me"),
onTap: () => modalBuilder(context),
);
},
),
);
}
Expand Down

0 comments on commit 170173a

Please sign in to comment.