Skip to content

Re-attach toggle button click handler after navigation#1445

Merged
pomianowski merged 1 commit intolepoco:mainfrom
jbryknar:main
Jun 10, 2025
Merged

Re-attach toggle button click handler after navigation#1445
pomianowski merged 1 commit intolepoco:mainfrom
jbryknar:main

Conversation

@jbryknar
Copy link
Copy Markdown
Collaborator

@jbryknar jbryknar commented Jun 9, 2025

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

The toggle button part of the SplitButton stops working if you navigate away from a page and then come back to it using the PageService navigation and the page is registered using AddSingleton.

The problem appears to be how the toggle button Click event is registered and unregistered. The toggle button Click event is registered in the OnApplyTemplate routine which is only executed the first time the page is displayed. It's unregistered in an Unloaded event which executes every time you navigate away from the page, so the second and subsequent times you navigate to the page, the Click event is no longer registered and that part of the SplitButton stops working.

This problem has been referenced here, but I don't see a committed functional solution anywhere: #1179

What is the new behavior?

The SplitButton now correctly reattaches the ToggleButton click event handler after navigating away from and back to the page. This ensures the toggle portion of the button remains functional even when the page is registered as a singleton and reused via the PageService.

@jbryknar jbryknar requested a review from pomianowski as a code owner June 9, 2025 14:47
@github-actions github-actions Bot added controls Changes to the appearance or logic of custom controls. PR Pull request dotnet release labels Jun 9, 2025
@pomianowski pomianowski merged commit 47cb53c into lepoco:main Jun 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

controls Changes to the appearance or logic of custom controls. dotnet PR Pull request release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants