slovnicki / beamer

A routing package built on top of Router and Navigator's pages API, supporting arbitrary nested navigation, guards and more.
MIT License
591 stars 129 forks source link

Data not passed to BeamGuard onCheckFailed. #599

Open calebvetter opened 1 year ago

calebvetter commented 1 year ago

Describe the bug I have data that I'm passing to my HomeLocation(). When a BeamGuard checks requirements, fails, and runs onCheckFailed, the location data originally passed is not present in location.data.

Beamer version: 1.5.3

To Reproduce Add BeamGuard to delegate.

BeamGuard(
  pathPatterns: ['/auth'],
  guardNonMatching: true,
  check: (_, __) => read(authenticatedProvider),
  onCheckFailed: (context, location) {
    print(location.data);
    return context.beamToNamed('/auth', data: location.data);
  },
),

Try to beam to a guarded page.

context.beamToNamed('/', data: {'myData': 'testData'});

The route is successfully intercepted, the location is the HomeLocation() as expected, but the location.data object is null, so it can't be passed on to the redirected page.

Expected behavior location.data in the onCheckFailed function to have the data passed in the original beamToNamed call.

tapizquent commented 1 year ago

I noticed that the data in also null within the check callback

slovnicki commented 1 year ago

Hey @calebvetter :wave: Thanks for creating an issue and sorry for my absence lately.

This sounds like a bug, indeed. I will investigate it over the weekend and push a fix. Thanks for the additional feedback @tapizquent