diff --git a/panel/models/card.ts b/panel/models/card.ts index 6b5e55c2347..05e987e39ef 100644 --- a/panel/models/card.ts +++ b/panel/models/card.ts @@ -200,8 +200,14 @@ export class CardView extends ColumnView { } _toggle_button(e: MouseEvent): void { - for (const path of e.composedPath()) { - if (path instanceof HTMLInputElement) { + const is_panel_widget = (el: EventTarget): boolean => + el instanceof HTMLInputElement || ( + el instanceof HTMLElement && + Array.from(el.classList).some((c) => c.startsWith("bk-panel-models-widgets-"))) + + for (const el of e.composedPath()) { + // If the click came from any Panel widget in the header, don't toggle. + if (is_panel_widget(el)) { return } } diff --git a/panel/tests/ui/layout/test_card.py b/panel/tests/ui/layout/test_card.py index caf481e729e..4d834867755 100644 --- a/panel/tests/ui/layout/test_card.py +++ b/panel/tests/ui/layout/test_card.py @@ -187,7 +187,7 @@ def test_card_scrollable(page): def test_card_widget_not_collapsed(page, card_components): # Fixes https://github.com/holoviz/panel/issues/7045 w1, w2 = card_components - card = Card(w1, header=Row(w2)) + card = Card("content", title="MyTitle", header=Row(w1, w2)) serve_component(page, card) @@ -199,5 +199,9 @@ def test_card_widget_not_collapsed(page, card_components): text_input.press("F") text_input.press("Enter") + slider_input = page.locator('.noUi-base') + expect(slider_input).to_have_count(1) + slider_input.click() + wait_until(lambda: w2.value == 'F', page) assert not card.collapsed