fix: Preserve slider bar color when accordion is collapsed/expanded - #8460
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8460 +/- ##
==========================================
+ Coverage 85.50% 86.05% +0.55%
==========================================
Files 349 349
Lines 55167 55184 +17
==========================================
+ Hits 47170 47491 +321
+ Misses 7997 7693 -304 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
philippjfr
approved these changes
Mar 3, 2026
SuMayaBee
force-pushed
the
fix-slider-coloring-issue
branch
from
March 3, 2026 16:32
4157b06 to
17a3149
Compare
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
While looking into issue #8121, I discovered that sliders inside Accordion components would lose their bar color (turn grey) after collapsing and expanding the accordion, regardless of whether the slider was disabled or enabled. The slider would initially show the correct teal color when enabled, but after collapsing and re-expanding the accordion, it would turn grey even when still enabled.
Before fix:
477479956-b1fb58f0-b6be-4bbb-8b3b-8986306d8885.webm
After fix:
PR_After7.mp4
Problem:
Looking into the codebase, I found that when an accordion is expanded, the
_collapse()method incard.tswas callingchild_view.render()followed bychild_view.after_render(). This triggered a full re-render of the slider widget, which caused Bokeh's_set_bar_color()method to run and apply an inlinebackground-colorstyle with Panel's default grey color (#e6e6e6) on the.noUi-connectelement. I discovered that this inline style was overriding the CSS default teal color (#3FB8AF) that should be displayed when the slider is enabled.Solution:
Replaced
child_view.render()+child_view.after_render()withchild_view.r_after_render()in the expand branch. This restores the DOM without a full re-render, preserving existing styles and avoiding the incorrect color override.Technical Details:
panel/models/card.ts→_collapse()methodchild_view.r_after_render()instead ofchild_view.render()+child_view.after_render()_set_bar_color()from applying incorrect inline stylesFixes #8121
How Has This Been Tested?
Manual Testing: Verified sliders maintain correct color (teal when enabled, grey when disabled) after accordion collapse/expand.
Automated Testing: Added UI test
test_slider_color_preserved_in_accordion()that tests all slider types (FloatSlider, IntSlider, EditableFloatSlider, EditableIntSlider) inside an Accordion and verifies color preservation after collapse/expand.Test Command:
AI Disclosure
Gemini 3 Flash is used to review the codebase and identify the root cause of the issue.
Checklist:
Tests added and is passing