Skip to content

Commit e0ff5f0

Browse files
committed
Close #100. Trigger resize after display, even if no filling is involved
1 parent f2ea825 commit e0ff5f0

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

js/src/output.ts

+20-19
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,28 @@ class IPyWidgetOutput extends Shiny.OutputBinding {
103103
}
104104

105105
// Only carry the potential to fill (i.e., add fill classes)
106-
// if `output_widget(fillable=True)`
107-
if (!el.classList.contains("html-fill-container")) return;
106+
// if `output_widget(fillable=True)` _and_ the widget wants to fill
107+
const fill = data.fill && el.classList.contains("html-fill-container");
108108

109-
// And only fill if the `Widget.layout.height` isn't set
110-
if (!data.fill) return;
111-
112-
// Make ipywidgets container (.lmWidget) a fill carrier
113-
// el should already be a fill carrier (done during markup generation)
109+
// The ipywidgets container (.lmWidget)
114110
const lmWidget = el.children[0] as HTMLElement;
115-
lmWidget?.classList.add("html-fill-container", "html-fill-item");
116-
117-
// lmWidget's children is the actual widget implementation.
118-
// Ideally this would be a single element, but some widget
119-
// implementations (e.g., pydeck, altair) have multiple direct children.
120-
// It seems relatively safe to make all of them fill items, but there's
121-
// at least one case where it's problematic (pydeck)
122-
lmWidget.childNodes.forEach((child) => {
123-
if (!(child instanceof HTMLElement)) return;
124-
if (child.classList.contains("deckgl-ui-elements-overlay")) return;
125-
child.classList.add("html-fill-item");
126-
});
111+
112+
if (fill) {
113+
// Make lmWidget a fill carrier
114+
// el should already be a fill carrier (done during markup generation)
115+
lmWidget?.classList.add("html-fill-container", "html-fill-item");
116+
117+
// lmWidget's children is the actual widget implementation.
118+
// Ideally this would be a single element, but some widget
119+
// implementations (e.g., pydeck, altair) have multiple direct children.
120+
// It seems relatively safe to make all of them fill items, but there's
121+
// at least one case where it's problematic (pydeck)
122+
lmWidget.childNodes.forEach((child) => {
123+
if (!(child instanceof HTMLElement)) return;
124+
if (child.classList.contains("deckgl-ui-elements-overlay")) return;
125+
child.classList.add("html-fill-item");
126+
});
127+
}
127128

128129
this._maybeResize(lmWidget);
129130
}

0 commit comments

Comments
 (0)