Skip to content

Get active Blazor page component #31280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kev160967 opened this issue Mar 26, 2021 · 2 comments
Closed

Get active Blazor page component #31280

kev160967 opened this issue Mar 26, 2021 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@kev160967
Copy link

I'd like to obtain a reference to the component object for the currently displayed page.

I'm writing a menu component with the goal of not allowing the user to navigate away from a page (via the menu) if the active page wishes to block it (for example, if it has uncommitted changes). Before initiating a page navigation my component would like to ask the current page component whether it should allow this or not, and if not then display a message generated by the current page explaining why. To support this my page components can implement an interface that supports the ability to check this state. To make use of this though, I need to be able to make a call through the active page's reference.

I can see a workaround where the page components update a state on the menu component to indicate if navigation should be blocked, but this has more risks (for example, if something causes a page not to release a block). It also feels like the wrong way around.

@Pilchie Pilchie added the area-blazor Includes: Blazor, Razor Components label Mar 26, 2021
@mkArtakMSFT
Copy link
Contributor

mkArtakMSFT commented Mar 29, 2021

Thanks for contacting us.
It looks like you're looking for a way to cancel navigation. For that we have a different issue planned, which we track as part of #14962

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Mar 29, 2021
@ghost ghost added the Status: Resolved label Mar 29, 2021
@kev160967
Copy link
Author

Thanks Artak, I was aware of the issue you linked, but I was hoping to get something in place for a system I have live at the moment, and (unless I've missed it) there's no release date announced for the changes described in that issue?

@ghost ghost locked as resolved and limited conversation to collaborators Apr 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants