Fix parameter plot toolbar visibility

Restore Plotly hover controls, keep controls visible on touch-only devices, and remove conflicting click toggles. Add regression coverage for toolbar visibility and retained marker interactions.
This commit is contained in:
salman committed 2026-11-04 15:32:40 +01:00
1 parent 6df649a4da
commit 3144befa69
3 files changed
+21 -29

No files matched your search

+5 -2
View File
@@ -1682,8 +1682,11 @@ button:not(.tablinks):not(.action-btn):not(.editor-source-tab):not(.status-state
position: relative;
}
.parameter-plot-window .js-plotly-plot .modebar {
display: none !important;
/* Touch-only devices cannot hover to reveal the Plotly toolbar. */
@media (hover: none) {
.parameter-plot-window .js-plotly-plot .modebar {
opacity: 1 !important;
}
}
.parameter-plot-window .js-plotly-plot .modebar-container,
.parameter-plot-window .js-plotly-plot .modebar {
+2 -27
View File
@@ -2117,7 +2117,8 @@ function showMusrfitParameterPlotWindow(parameterPath, jobName = "", preferredPa
editable: true,
edits: { titleText: false, legendText: true },
displaylogo: false,
displayModeBar: false,
// Let Plotly handle toolbar visibility without intercepting plot clicks.
displayModeBar: "hover",
modeBarButtonsToAdd: [
{
@@ -2154,32 +2155,6 @@ function showMusrfitParameterPlotWindow(parameterPath, jobName = "", preferredPa
});
if (!panel.clickAttached && typeof panel.chart.on === "function") {
panel.clickAttached = true;
var toggleModeBar = function(e) {
try {
var modeBar = panel.chart.querySelector(".modebar") || document.querySelector(".js-plotly-plot .modebar");
if (!modeBar && panel.chart.parentElement) {
modeBar = panel.chart.parentElement.querySelector(".modebar");
}
if (!modeBar) return;
var st = window.getComputedStyle ? window.getComputedStyle(modeBar) : {};
if (st.display !== "none" && modeBar.style.display !== "none") {
modeBar.style.display = "none";
} else {
modeBar.style.display = "flex";
modeBar.style.visibility = "visible";
}
} catch (ex) {}
};
if (panel.chart && typeof panel.chart.addEventListener === "function") {
panel.chart.addEventListener("click", toggleModeBar, true);
panel.chart.addEventListener("mousedown", toggleModeBar, true);
}
if (panel.chart && typeof panel.chart.addEventListener === "function") {
panel.chart.addEventListener("touchend", toggleModeBar, { passive: true });
}
if (panel.element && typeof panel.element.addEventListener === "function") {
panel.element.addEventListener("click", toggleModeBar, true);
}
// Map a click on a plotted marker back to its (data set, parameter)
// series and offer style editing in a small popover near the pointer.
panel.chart.on("plotly_click", function(clickEvent) {
+14
View File
@@ -1145,6 +1145,20 @@ function testAxisScaleSurvivesRefresh() {
}), true);
}
function testParameterToolbarVisibility() {
const plot = fs.readFileSync(path.join(repoRoot, "muSRFitParameterPlot.js"), "utf8");
const css = fs.readFileSync(path.join(repoRoot, "ZGUI.css"), "utf8");
assert.match(plot, /displayModeBar: "hover"/);
assert.doesNotMatch(plot, /toggleModeBar/);
assert.doesNotMatch(css, /\.modebar\s*\{[^}]*display:\s*none/);
assert.match(css, /@media \(hover: none\)\s*\{\s*\.parameter-plot-window \.js-plotly-plot \.modebar\s*\{\s*opacity: 1 !important/);
// Marker styling must remain available after removing the generic click handlers.
assert.match(plot, /panel\.chart\.on\("plotly_click"/);
}
testParameterToolbarVisibility();
testParserAndSmartDefaults();
testScanVariableDetection();
testTfTemplateApplication();