mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Reported on a board in mobile mode in desktop Firefox: widening the window made the
swimlanes, lists and cards taller; narrowing it shrank them again. The same complaint
as /sign-in and /sign-up, and the same cause - a size measured against the WINDOW
instead of being a size.
The earlier sweep converted 355 bare `vh`/`vw` values but explicitly ALLOWED
`min()`, `max()` and `clamp()`, on the grounds that they are caps. `clamp()` is not.
It is only a cap at its two ends; between them it tracks the viewport exactly like a
bare `vw`. So `font-size: clamp(18px, 2.5vw, 32px)` on a swimlane header, a list
header and a minicard is a font that grows with the window - and since those rows are
sized by their text, the rows grow with it. There were 75 of these across 17
stylesheets, 36 of them in the mobile-mode board rules.
All 75 are converted to the size they already rendered at on a phone - the lower bound
of each clamp. That is the value these rules were designed around (below ~800px the
clamp was pinned to it anyway), it is in line with the rest of the UI's fixed sizes,
and picking the upper bound instead would have made every phone bigger than it is
today.
Also converted, same behaviour by other spellings:
* `.board-sidebar { width: clamp(320px, 30vw, 560px) }` -> a fixed 420px. Its own
comment recorded 420px as the intended width; the clamp was added to stop a bare
30vw doubling on wide screens, but it still resized in between.
* `min-height: 3vh` on the mobile minicard -> 24px.
* `min-height: 60vh` on a collapsed list -> 540px, which is exactly what the
`height: 540px` on the very next line already says.
* `min-height: 60vh` (settings body) -> 540px; `min-height: 14vh` (search popover)
-> 126px.
* `max-width: 13vw` on a minicard custom-field chip -> 160px.
tests/noViewportSpacing.test.cjs no longer allows clamp() or a viewport `min-*`, and
says why. What stays allowed is a full-viewport box (100vh/100vw), a `max-height` /
`max-width` cap, and `min(400px, 52vw)` - a shrink-only cap, flat at the px above the
crossover width and giving way only below it so a box fits a narrow screen. It never
grows with the window, so it is not this bug; `max(...)`, which does grow without
bound, is not allowed. Both argument orders are accepted.
tests/sidebarWidth.test.cjs required `clamp()` for the sidebar - that was the fix for
the doubling, and it is now the thing being removed. It asks for a fixed px width and
no viewport unit at all, which is a stronger form of what it was guarding.
Tests: 1321 passing.
Thanks to xet7 !
65 lines
2.5 KiB
JavaScript
65 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
// Regression guard for the right board sidebar (Filter / Search / etc.) width
|
|
// and its input fields.
|
|
//
|
|
// - The panel used `width: 30vw`, which scaled with the viewport: on very wide
|
|
// screens it grew to ~double the intended width (looking right only at mid
|
|
// widths). A clamp() bounded it, but between its two ends a clamp still tracks the
|
|
// window - the same "elements resize when I resize the browser" behaviour reported
|
|
// later for the board. It is now a fixed 420px: the width it was designed at.
|
|
// - The filter text inputs (Filter List by Title, Filter by card title, ...) had
|
|
// no width, so they rendered at the browser's default narrow width with a big
|
|
// empty gap on the right instead of equal spacing on both sides. Sidebar text
|
|
// inputs must fill the padded content width.
|
|
//
|
|
// Run: node tests/sidebarWidth.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
const css = fs.readFileSync(
|
|
path.join(__dirname, '..', 'client/components/sidebar/sidebar.css'), 'utf8');
|
|
|
|
function block(selector) {
|
|
const i = css.indexOf(selector + ' {');
|
|
assert.ok(i >= 0, `rule ${selector} must exist`);
|
|
return css.slice(i, css.indexOf('}', i));
|
|
}
|
|
|
|
console.log('sidebarWidth:');
|
|
|
|
test('.board-sidebar width is fixed, not scaling with the viewport', () => {
|
|
const b = block('.board-sidebar');
|
|
assert.ok(/width:\s*\d+px/.test(b),
|
|
'.board-sidebar must have a fixed px width, so it does not resize with the window');
|
|
assert.ok(!/width:[^;]*v[hw]/.test(b),
|
|
'and no viewport unit in it, clamped or otherwise');
|
|
});
|
|
|
|
test('no `width: 30vw;` remains anywhere', () => {
|
|
// The declaration that caused the doubling, in any form.
|
|
assert.ok(!/width:\s*30vw\s*;/.test(css),
|
|
'a bare width: 30vw; must not be present (must be clamped)');
|
|
});
|
|
|
|
test('sidebar text inputs fill the padded content width (symmetric spacing)', () => {
|
|
// The rule targets text/search inputs in the sidebar content.
|
|
const m = css.match(
|
|
/\.sidebar\s+\.sidebar-content\s+input\[type="text"\][\s\S]{0,160}?\{([\s\S]*?)\}/);
|
|
assert.ok(m, 'a width rule for .sidebar .sidebar-content input[type="text"] must exist');
|
|
assert.ok(/width:\s*100%/.test(m[1]), 'sidebar text inputs must be width: 100%');
|
|
assert.ok(/box-sizing:\s*border-box/.test(m[1]),
|
|
'box-sizing: border-box keeps the border inside the width');
|
|
});
|
|
|
|
console.log(`\n${passed} passed`);
|