Skip to content

Get active Blazor page component #31280

Closed
@kev160967

Description

@kev160967

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions