Fixed visibility toggling of a horizontal or vertical panel#32
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a visibility toggling bug in nested slider panels by implementing proper cleanup through IDisposable. When conditional rendering destroyed and recreated panels, stale parent-child references caused panels to disappear incorrectly. The solution adds IDisposable to both HorizontalSliderPanel and VerticalSliderPanel, ensuring parent references are cleaned up when components are destroyed.
- Implements IDisposable in HorizontalSliderPanel and VerticalSliderPanel with Dispose methods that clean up parent-child references
- Adds test pages (Visibility.razor) in both WASM and Server test apps to demonstrate and verify the fix
- Refactors property declarations to use single-line [Parameter] attribute format for consistency
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| BlazorSliders/VerticalSliderPanel.razor.cs | Implements IDisposable and Dispose method to clean up parent references; refactors parameter declarations to single-line format |
| BlazorSliders/HorizontalSliderPanel.razor.cs | Implements IDisposable and Dispose method to clean up parent references; refactors parameter declarations to single-line format |
| BlazorSlidersWasmTestApp/Pages/Visibility.razor | Adds test page demonstrating nested slider panels with conditional rendering to verify the fix |
| BlazorSlidersWasmTestApp/Pages/NavMenu.razor | Adds navigation link to new Visibility test page |
| BlazorSlidersServerTestApp/Components/Pages/Visibility.razor | Adds identical test page for Server test app |
| BlazorSlidersServerTestApp/Components/Pages/NavMenu.razor | Adds navigation link to new Visibility test page |
| BlazorSliders.sln | Updates Visual Studio version metadata |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| protected string TopPanelHeightPx | ||
| { | ||
| get { return topPanelHeight.ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
|
|
||
| protected string BottomPanelHeightPx | ||
| { | ||
| get { return BottomPanelHeight.ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
| protected string SliderHeightPx { get { return SliderHeight.ToString() + "px"; } } | ||
| protected string BottomPanelTopPx | ||
| { | ||
| get { return (topPanelHeight + SliderHeight).ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
|
|
||
| protected string SliderHeightPx | ||
| { | ||
| get { return SliderHeight.ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
|
|
||
| protected string LeftPanelWidthPx | ||
| { | ||
| get { return leftPanelWidth.ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
|
|
||
| protected string RightPanelWidthPx | ||
| { | ||
| get { return RightPanelWidth.ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
|
|
||
| protected string RightPanelLeftPx | ||
| { | ||
| get { return (leftPanelWidth + SliderWidth).ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
|
|
||
| protected string SliderWidthPx | ||
| { | ||
| get { return SliderWidth.ToString() + "px"; } |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
Added IDisposable implementation to HorizontalSliderPanel and VerticalSliderPanel to properly clean up parent panel references when components are destroyed during conditional rendering, fixing the bug where nested panels would alternately disappear when toggled due to stale parent-child references.