Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions npm/qsharp/ux/qsharp-ux.css
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,6 @@ html {

/* Space chart */

/* Needed until https://github.com/microsoft/vscode-jupyter/issues/7161 is resolved */
.cell-output-ipywidget-background {
background-color: transparent !important;
}

#pieChart {
fill: var(--main-color);
}
Expand Down
16 changes: 16 additions & 0 deletions widgets/js/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ type RenderArgs = {
export function render({ model, el }: RenderArgs) {
const componentType = model.get("comp");

// There is an existing issue where in VS Code it always shows the widget background as white.
// (See https://github.com/microsoft/vscode-jupyter/issues/7161)
// We tried to fix this in CSS by overridding the style, but there is a race condition whereby
// depending on which style gets injected first (ours or ipywidgets), it may or may not work.

// The solution here is to force our own override to be last in the style list if not already.
// It's a bit of a hack, but it works, and I couldn't find something better that wouldn't be fragile.

if (
!el.ownerDocument.head.lastChild?.textContent?.includes("widget-css-fix")
) {
const forceStyle = el.ownerDocument.createElement("style");
forceStyle.textContent = `/* widget-css-fix */ .cell-output-ipywidget-background {background-color: transparent !important;}`;
el.ownerDocument.head.appendChild(forceStyle);
}

switch (componentType) {
case "SpaceChart":
renderChart({ model, el });
Expand Down
Loading