rdkcentral / Lightning-SDK

SDK for Lightning framework
Apache License 2.0
130 stars 69 forks source link

Fixed router back track issue #386

Closed sandeep-vedam closed 1 year ago

sandeep-vedam commented 1 year ago

Fixed issue related to Router backtrack. Here is the issue

When the router is configured with backtrack as true and the user enters App via a deeplink, clicking on the handle back results in either closing or showing an exit dialog if the app has.

This fix will serve when the user enters the deeplink and user presses the back button:

  1. Backtrack: enabled -> Application recursively removes the last part of the hash until it finds a valid path to navigate. In case there is no valid hash then it should exit the application.
  2. Backtrack: disabled -> Application is closed
ricardo-a-alves-alb commented 1 year ago

How about when we have the root property defined? Shouldn't it navigate to the root page before triggering the _handleAppClose callback?

imtiaz101325 commented 1 year ago

Hey @sandeep-vedam, I'm also with @ricardo-a-alves-alb here. We have recently found this behavior and and have added a handler on the root component to solve this. Some apps might want to close the app when hitting back like this.

Edit: took a look at #385 -- I probably mixed up context 😅.

The application should recursively remove the last part of the has until it finds a valid path to navigate. In case there is no valid hash then it should exit the application.

Sounds like handle back to close is covered and the PR addresses a different issue. Good stuff 👍🏾

erikhaandrikman commented 1 year ago

How about when we have the root property defined? Shouldn't it navigate to the root page before triggering the _handleAppClose callback?

@ricardo-a-alves-alb this does sound like a good suggestion. For now we're going to merge this PR as is, since it's fixes the broken backtrack functionality. We should probably discuss your suggested change for the next release