Skip to content

Commit ab5adb3

Browse files
emunsingphilippjfr
andauthored
Interactive widgets in header- fixes #8353 (#8357)
* Handle other widgets * Updated UI test * Combine old and new condition * Apply suggestions from code review --------- Co-authored-by: Philipp Rudiger <prudiger@anaconda.com>
1 parent a246fc5 commit ab5adb3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

panel/models/card.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,14 @@ export class CardView extends ColumnView {
215215
}
216216

217217
_toggle_button(e: MouseEvent): void {
218-
for (const path of e.composedPath()) {
219-
if (path instanceof HTMLInputElement) {
218+
const is_panel_widget = (el: EventTarget): boolean =>
219+
el instanceof HTMLInputElement || (
220+
el instanceof HTMLElement &&
221+
Array.from(el.classList).some((c) => c.startsWith("bk-panel-models-widgets-")))
222+
223+
for (const el of e.composedPath()) {
224+
// If the click came from any Panel widget in the header, don't toggle.
225+
if (is_panel_widget(el)) {
220226
return
221227
}
222228
}

panel/tests/ui/layout/test_card.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_card_scrollable(page):
187187
def test_card_widget_not_collapsed(page, card_components):
188188
# Fixes https://github.com/holoviz/panel/issues/7045
189189
w1, w2 = card_components
190-
card = Card(w1, header=Row(w2))
190+
card = Card("content", title="MyTitle", header=Row(w1, w2))
191191

192192
serve_component(page, card)
193193

@@ -199,6 +199,10 @@ def test_card_widget_not_collapsed(page, card_components):
199199
text_input.press("F")
200200
text_input.press("Enter")
201201

202+
slider_input = page.locator('.noUi-base')
203+
expect(slider_input).to_have_count(1)
204+
slider_input.click()
205+
202206
wait_until(lambda: w2.value == 'F', page)
203207
assert not card.collapsed
204208

0 commit comments

Comments
 (0)