Skip to content

Commit f4e77cd

Browse files
committed
Let the console header wrap, so the device stops sliding off-centre
Reported as bad scaling in the inspector: the overlay boxes did not sit on the elements they described. The mapping was right — a node computed to 7.96% left and 84.08% wide, exactly what its frame implies — and the overlay tracked the canvas precisely. Both had simply been moved. The header is 1014px of controls. In a window narrower than that it overflowed, and clicking Inspect, which sits near its right end, scrolled the page sideways to bring the button into view: scrollX went from 0 to 152 and the stage went with it, carrying the device and its overlay off-centre. Nothing was mis-scaled; the whole layout had been dragged. The header now wraps and the app-id input can shrink, so at 806px the header measures 806 and scrollX stays 0 through the click. Verified at that width: the device sits fully inside the stage and a node box lands at 8.0% left, 84.1% wide within the canvas, matching its frame.
1 parent 53e000e commit f4e77cd

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎internal/web/static/style.css‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ header {
2828
padding: 8px 12px;
2929
background: var(--panel);
3030
border-bottom: 1px solid var(--edge);
31+
/* Wrap rather than overflow. A header wider than the window is not
32+
merely clipped: focusing a control near its right edge scrolls the
33+
whole page sideways, and the device and its inspector overlay slide
34+
off-centre together — which reads as broken scaling rather than as
35+
a layout that did not fit. */
36+
flex-wrap: wrap;
3137
}
3238

3339
.brand { font-weight: 700; letter-spacing: 0.02em; margin-right: 8px; }
@@ -42,7 +48,8 @@ select, input, button {
4248
font: inherit;
4349
}
4450

45-
input#app { width: 230px; }
51+
/* Roomy when there is space, shrinkable when there is not. */
52+
input#app { width: 230px; flex: 0 1 230px; min-width: 110px; }
4653
button { cursor: pointer; }
4754
button:hover { border-color: var(--accent); }
4855
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

‎internal/web/web_test.go‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,20 @@ func TestConsoleWiresSharedModules(t *testing.T) {
5656
}
5757
}
5858
}
59+
60+
// The console header must be able to wrap. Wider than the window, it is
61+
// not merely clipped: focusing a control near its right edge scrolls the
62+
// page sideways, and the device and its inspector overlay slide
63+
// off-centre together, which reads as broken scaling rather than as a
64+
// header that did not fit.
65+
func TestConsoleHeaderWraps(t *testing.T) {
66+
css := get(t, "/style.css").Body.String()
67+
header := css[strings.Index(css, "header {"):]
68+
header = header[:strings.Index(header, "}")]
69+
if !strings.Contains(header, "flex-wrap: wrap") {
70+
t.Errorf("header must wrap rather than overflow:\n%s", header)
71+
}
72+
if !strings.Contains(css, "input#app") || !strings.Contains(css, "min-width: 110px") {
73+
t.Error("the app-id input must be allowed to shrink")
74+
}
75+
}

0 commit comments

Comments
 (0)