anvil-works / routing

routing - Built with Anvil
https://routing-docs.anvil.works
MIT License
2 stars 1 forks source link

Handle alerts when the back button is pressed #31

Closed jshaffstall closed 1 week ago

jshaffstall commented 1 week ago

Currently the form shown is changed when the back button is pressed, but if an alert is showing the alert remains showing. Hash routing prevented the back button from working when a non-dismissible alert was shown, and dismissed ones that could be dismissed.

I figure this is already on the list, but ran across it today so submitted it just in case.

s-cork commented 1 week ago

@jshaffstall - try 0.3.2

you'll need to do as hash routing does

import anvil
from routing import router

anvil.alert = router.alert
anvil.confirm = router.confirm
jshaffstall commented 1 week ago

That works, thanks! That should probably be a standard addition to the example startup module in the docs (or at least a note about that being where it would go if you want alerts to prevent navigation automatically)

s-cork commented 1 week ago

yeah - the docs have been updated You can find it in the api reference and in blocking navigation

There is also a "Kitchen Sink" app in the works that will include this in the startup module