@schukai/monster 5.2.4 → 5.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
 
4
4
 
5
+ ## [5.2.6] - 2026-11-17
6
+
7
+ ### Bug Fixes
8
+
9
+ - **popper:** let nested horizontal overlays escape scrolling ([#612](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/612))
10
+
11
+
12
+
13
+ ## [5.2.5] - 2026-11-17
14
+
15
+ ### Bug Fixes
16
+
17
+ - **floating:** ignore boxless clipping ancestors ([#610](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/610))
18
+ - **panel:** ignore unpainted outline widths in height calculations ([#611](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/611))
19
+
20
+
21
+
5
22
  ## [5.2.4] - 2026-11-16
6
23
 
7
24
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./documentation/migrations/monster-5-options.md":"./documentation/migrations/monster-5-options.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","documentation/migrations/monster-5-options.md","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.2.4"}
1
+ {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./documentation/migrations/monster-5-options.md":"./documentation/migrations/monster-5-options.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","documentation/migrations/monster-5-options.md","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.2.6"}
@@ -265,12 +265,23 @@ function isPositionedPopperOpen(popperElement) {
265
265
  }
266
266
 
267
267
  function normalizePopperConfig(options, controlElement, popperElement) {
268
+ // Keep ordinary content scrollable while implicit nested overlays escape it.
269
+ // Explicit strategies still override this default below.
270
+ const parentContent = resolveParentPopperContentBoundary(
271
+ controlElement,
272
+ popperElement,
273
+ );
274
+ const defaultStrategy =
275
+ parentContent?.dataset.monsterOverflowMode === "horizontal" &&
276
+ isClippingContainer(getComputedStyle(parentContent))
277
+ ? "fixed"
278
+ : "absolute";
268
279
  const config = Object.assign(
269
280
  {},
270
281
  {
271
282
  placement: "top",
272
283
  engine: "floating",
273
- strategy: "absolute",
284
+ strategy: defaultStrategy,
274
285
  adaptiveSize: true,
275
286
  hideWhenReferenceHidden: false,
276
287
  },
@@ -1267,7 +1278,10 @@ function isPopperContentWrapper(element) {
1267
1278
  }
1268
1279
 
1269
1280
  function isClippingContainer(style) {
1270
- if (!style) {
1281
+ // display: contents generates no box, so its overflow cannot clip descendants.
1282
+ // Keep this decision shared by boundary resolution and visibility checks;
1283
+ // a zero-sized element that does generate a box must still clip normally.
1284
+ if (!style || style.display === "contents") {
1271
1285
  return false;
1272
1286
  }
1273
1287
 
@@ -229,7 +229,9 @@ function calculateMaximumHeight(element) {
229
229
  const marginBottom = parseFloat(style.marginBottom);
230
230
 
231
231
  // Outline and box-shadow
232
- const outlineHeight = parseFloat(style.outlineWidth);
232
+ // Some browsers resolve a nonzero width even when no outline is painted.
233
+ const outlineHeight =
234
+ style.outlineStyle === "none" ? 0 : parseFloat(style.outlineWidth);
233
235
  // This is a simplification; box-shadow is more complex to parse
234
236
  const boxShadowVertical = parseFloat(style.boxShadow.split(" ")[3] || 0);
235
237
 
@@ -156,7 +156,7 @@ function getMonsterVersion() {
156
156
  }
157
157
 
158
158
  /** Managed by the release script; keep synchronized with package.json. */
159
- monsterVersion = new Version("5.2.4");
159
+ monsterVersion = new Version("5.2.6");
160
160
 
161
161
  return monsterVersion;
162
162
  }
@@ -4,12 +4,15 @@ import { initJSDOM } from "../../../util/jsdom.mjs";
4
4
  let expect = chai.expect;
5
5
 
6
6
  let resolveClippingBoundaryElement;
7
+ let resolveParentPopperContentBoundary;
7
8
  let applyAdaptiveFloatingElementSize;
8
9
  let applyFloatingReferenceVisibility;
9
10
  let createVisibilityRecoveryConfig;
10
11
  let getFloatingVisibleRatio;
11
12
  let resolveFloatingArrowStaticOffset;
12
13
  let resetAdaptiveFloatingElementSize;
14
+ let openPositionedPopper;
15
+ let closePositionedPopper;
13
16
 
14
17
  describe("form floating-ui boundary resolution", function () {
15
18
  before(function (done) {
@@ -21,6 +24,8 @@ describe("form floating-ui boundary resolution", function () {
21
24
  })
22
25
  .then((m) => {
23
26
  resolveClippingBoundaryElement = m.resolveClippingBoundaryElement;
27
+ resolveParentPopperContentBoundary =
28
+ m.resolveParentPopperContentBoundary;
24
29
  applyAdaptiveFloatingElementSize = m.applyAdaptiveFloatingElementSize;
25
30
  applyFloatingReferenceVisibility = m.applyFloatingReferenceVisibility;
26
31
  createVisibilityRecoveryConfig = m.createVisibilityRecoveryConfig;
@@ -28,6 +33,8 @@ describe("form floating-ui boundary resolution", function () {
28
33
  resolveFloatingArrowStaticOffset =
29
34
  m.resolveFloatingArrowStaticOffset;
30
35
  resetAdaptiveFloatingElementSize = m.resetAdaptiveFloatingElementSize;
36
+ openPositionedPopper = m.openPositionedPopper;
37
+ closePositionedPopper = m.closePositionedPopper;
31
38
  done();
32
39
  })
33
40
  .catch((e) => done(e));
@@ -38,6 +45,50 @@ describe("form floating-ui boundary resolution", function () {
38
45
  mocks.innerHTML = "";
39
46
  });
40
47
 
48
+ for (const [mode, overflow, strategy, expected] of [
49
+ ["horizontal", "auto", undefined, "fixed"],
50
+ ["horizontal", "auto", "absolute", "absolute"],
51
+ ["horizontal", "auto", "fixed", "fixed"],
52
+ ["horizontal", "visible", undefined, "absolute"],
53
+ ["both", "auto", undefined, "absolute"],
54
+ ["visible", "visible", undefined, "absolute"],
55
+ ]) {
56
+ it(`preserves positioning for ${mode}/${overflow}/${strategy ?? "implicit"} (#612)`, () => {
57
+ const parent = document.createElement("div");
58
+ parent.dataset.monsterRole = "popper";
59
+ const content = document.createElement("div");
60
+ content.setAttribute("part", "content");
61
+ content.dataset.monsterOverflowMode = mode;
62
+ content.style.overflow = overflow;
63
+ const reference = document.createElement("button");
64
+ const floating = document.createElement("div");
65
+ parent.append(content);
66
+ content.append(reference, floating);
67
+ document.getElementById("mocks").append(parent);
68
+ const options = strategy ? { strategy } : {};
69
+ openPositionedPopper(reference, floating, options);
70
+ expect(floating.style.position).to.equal(expected);
71
+ expect(options).to.deep.equal(strategy ? { strategy } : {});
72
+ closePositionedPopper(floating);
73
+ });
74
+ }
75
+
76
+ it("resolves horizontal clipping through a slot without changing standalone defaults (#612)", () => {
77
+ const reference = document.createElement("button");
78
+ const floating = document.createElement("div");
79
+ document.getElementById("mocks").append(reference, floating);
80
+ openPositionedPopper(reference, floating, {});
81
+ expect(floating.style.position).to.equal("absolute");
82
+ closePositionedPopper(floating);
83
+ const host = document.createElement("div");
84
+ host.attachShadow({ mode: "open" }).innerHTML = '<div data-monster-role="popper"><div part="content" data-monster-overflow-mode="horizontal" style="overflow:auto"><slot></slot></div></div>';
85
+ host.append(reference, floating);
86
+ document.getElementById("mocks").append(host);
87
+ openPositionedPopper(reference, floating, {});
88
+ expect(floating.style.position).to.equal("fixed");
89
+ closePositionedPopper(floating);
90
+ });
91
+
41
92
  it("should overlap the popper edge by half of the rendered arrow size", function () {
42
93
  expect(resolveFloatingArrowStaticOffset(8)).to.equal(-4);
43
94
  expect(resolveFloatingArrowStaticOffset(0)).to.equal(0);
@@ -77,6 +128,209 @@ describe("form floating-ui boundary resolution", function () {
77
128
  expect(resolveClippingBoundaryElement(control, popper)).to.equal(wrapper);
78
129
  });
79
130
 
131
+ describe("boxless clipping ancestors (#610)", function () {
132
+ const rect = (left, top, width, height) => ({
133
+ x: left,
134
+ y: top,
135
+ left,
136
+ top,
137
+ width,
138
+ height,
139
+ right: left + width,
140
+ bottom: top + height,
141
+ });
142
+ const mount = () => {
143
+ const wrapper = document.createElement("div");
144
+ const reference = document.createElement("div");
145
+ const popper = document.createElement("div");
146
+ wrapper.getBoundingClientRect = () => rect(0, 0, 0, 0);
147
+ reference.getBoundingClientRect = () => rect(100, 100, 100, 40);
148
+ popper.getBoundingClientRect = () => rect(100, 140, 200, 100);
149
+ wrapper.append(reference, popper);
150
+ document.getElementById("mocks").append(wrapper);
151
+ return { wrapper, reference, popper };
152
+ };
153
+
154
+ for (const [property, value] of [
155
+ ["overflow", "hidden"],
156
+ ["overflow", "auto"],
157
+ ["overflow", "scroll"],
158
+ ["overflow", "clip"],
159
+ ["overflowX", "hidden"],
160
+ ["overflowY", "auto"],
161
+ ]) {
162
+ it(`ignores display: contents with ${property}: ${value} for boundaries and visibility`, function () {
163
+ const { wrapper, reference, popper } = mount();
164
+ wrapper.style.display = "contents";
165
+ wrapper.style[property] = value;
166
+
167
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
168
+ null,
169
+ );
170
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
171
+ true,
172
+ );
173
+ expect(getFloatingVisibleRatio(popper)).to.equal(1);
174
+ });
175
+
176
+ it(`preserves a genuinely zero-sized box with ${property}: ${value}`, function () {
177
+ const { wrapper, reference, popper } = mount();
178
+ wrapper.style.display = "block";
179
+ wrapper.style[property] = value;
180
+
181
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
182
+ wrapper,
183
+ );
184
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
185
+ false,
186
+ );
187
+ expect(popper.dataset.monsterReferenceHidden).to.equal("true");
188
+ expect(getFloatingVisibleRatio(popper)).to.equal(0);
189
+ });
190
+ }
191
+
192
+ it("continues through nested contents wrappers to a real clipping ancestor", function () {
193
+ const { wrapper, reference, popper } = mount();
194
+ wrapper.style.cssText = "display: contents; overflow: hidden";
195
+ const inner = document.createElement("div");
196
+ inner.style.cssText = "display: contents; overflow: auto";
197
+ inner.append(reference, popper);
198
+ wrapper.append(inner);
199
+ const outer = document.createElement("div");
200
+ outer.style.overflow = "hidden";
201
+ outer.getBoundingClientRect = () => rect(50, 50, 150, 150);
202
+ wrapper.replaceWith(outer);
203
+ outer.append(wrapper);
204
+
205
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(outer);
206
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
207
+ true,
208
+ );
209
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
210
+
211
+ // A partially visible reference remains usable; a fully clipped one hides.
212
+ reference.getBoundingClientRect = () => rect(180, 100, 100, 40);
213
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
214
+ true,
215
+ );
216
+ reference.getBoundingClientRect = () => rect(200, 100, 100, 40);
217
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
218
+ false,
219
+ );
220
+ });
221
+
222
+ it("does not skip a real inner clipping box below a contents ancestor", function () {
223
+ const { wrapper, reference, popper } = mount();
224
+ wrapper.style.cssText = "display: contents; overflow: hidden";
225
+ const inner = document.createElement("div");
226
+ inner.style.overflow = "auto";
227
+ inner.getBoundingClientRect = () => rect(50, 50, 150, 150);
228
+ inner.append(reference, popper);
229
+ wrapper.append(inner);
230
+
231
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(inner);
232
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
233
+ true,
234
+ );
235
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
236
+ });
237
+
238
+ for (const composedAncestor of ["shadow host", "slot"]) {
239
+ it(`traverses a boxless ${composedAncestor} while preserving its real outer boundary`, function () {
240
+ const { wrapper, reference, popper } = mount();
241
+ wrapper.style.overflow = "hidden";
242
+ wrapper.getBoundingClientRect = () => rect(50, 50, 150, 150);
243
+ const host = document.createElement("div");
244
+ const shadow = host.attachShadow({ mode: "open" });
245
+ wrapper.append(host);
246
+ if (composedAncestor === "shadow host") {
247
+ host.style.cssText = "display: contents; overflow: hidden";
248
+ shadow.append(reference, popper);
249
+ } else {
250
+ const slot = document.createElement("slot");
251
+ slot.style.cssText = "display: contents; overflow: hidden";
252
+ shadow.append(slot);
253
+ host.append(reference, popper);
254
+ expect(reference.assignedSlot).to.equal(slot);
255
+ }
256
+
257
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
258
+ wrapper,
259
+ );
260
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
261
+ true,
262
+ );
263
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
264
+ });
265
+ }
266
+
267
+ it("reevaluates contents/block changes and restores reference visibility", function () {
268
+ const { wrapper, reference, popper } = mount();
269
+ wrapper.style.cssText = "display: contents; overflow: hidden";
270
+ for (const display of ["contents", "block", "contents"]) {
271
+ wrapper.style.display = display;
272
+ const hasBox = display === "block";
273
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
274
+ hasBox ? wrapper : null,
275
+ );
276
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
277
+ !hasBox,
278
+ );
279
+ expect(getFloatingVisibleRatio(popper)).to.equal(hasBox ? 0 : 1);
280
+ expect(popper.style.visibility).to.equal(hasBox ? "hidden" : "");
281
+ expect(popper.dataset.monsterReferenceHidden).to.equal(
282
+ hasBox ? "true" : undefined,
283
+ );
284
+ }
285
+ expect(wrapper.style.overflow).to.equal("hidden");
286
+ });
287
+
288
+ it("preserves nested popup boundary escape without losing real content clipping", function () {
289
+ const { wrapper, reference, popper } = mount();
290
+ wrapper.style.cssText = "display: contents; overflow: hidden";
291
+ const outer = document.createElement("div");
292
+ outer.style.overflow = "hidden";
293
+ outer.getBoundingClientRect = () => rect(0, 0, 500, 500);
294
+ const parentPopper = document.createElement("div");
295
+ parentPopper.dataset.monsterRole = "popper";
296
+ const content = document.createElement("div");
297
+ content.setAttribute("part", "content");
298
+ content.dataset.monsterOverflowMode = "both";
299
+ content.style.overflow = "auto";
300
+ content.getBoundingClientRect = () => rect(50, 50, 150, 150);
301
+ wrapper.replaceWith(outer);
302
+ outer.append(parentPopper);
303
+ parentPopper.append(content);
304
+ content.append(wrapper);
305
+
306
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(outer);
307
+ expect(resolveParentPopperContentBoundary(reference, popper)).to.equal(
308
+ content,
309
+ );
310
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
311
+ true,
312
+ );
313
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
314
+ reference.getBoundingClientRect = () => rect(220, 100, 100, 40);
315
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
316
+ false,
317
+ );
318
+ });
319
+
320
+ it("still clips against the viewport above a contents wrapper", function () {
321
+ const { wrapper, reference, popper } = mount();
322
+ wrapper.style.cssText = "display: contents; overflow: hidden";
323
+ reference.getBoundingClientRect = () => rect(100, -40, 100, 40);
324
+ popper.getBoundingClientRect = () => rect(100, -50, 200, 100);
325
+
326
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(null);
327
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
328
+ false,
329
+ );
330
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.5);
331
+ });
332
+ });
333
+
80
334
  it("should adapt the content max height to the available popper height", function () {
81
335
  const mocks = document.getElementById("mocks");
82
336
  const popper = document.createElement("div");
@@ -42,9 +42,26 @@ describe("SplitScreen", () => {
42
42
  });
43
43
 
44
44
  describe("document.createElement()", () => {
45
+ let originalInnerHeight;
46
+ let originalMocksStyle;
47
+ beforeEach(() => {
48
+ originalInnerHeight = Object.getOwnPropertyDescriptor(
49
+ window,
50
+ "innerHeight",
51
+ );
52
+ originalMocksStyle = document
53
+ .getElementById("mocks")
54
+ .getAttribute("style");
55
+ });
56
+
45
57
  afterEach(() => {
46
58
  const mocks = document.getElementById("mocks");
47
59
  mocks.innerHTML = "";
60
+ if (originalMocksStyle === null) mocks.removeAttribute("style");
61
+ else mocks.setAttribute("style", originalMocksStyle);
62
+ if (originalInnerHeight)
63
+ Object.defineProperty(window, "innerHeight", originalInnerHeight);
64
+ else delete window.innerHeight;
48
65
  });
49
66
 
50
67
  it("should have buttons and SplitScreen", (done) => {
@@ -93,5 +110,73 @@ describe("SplitScreen", () => {
93
110
  }
94
111
  }, 0);
95
112
  });
113
+
114
+ describe("outline height allowances (#611)", () => {
115
+ const mount = ({ panelOutline, parentOutline, parentHeight = 1000 }) => {
116
+ const parent = document.createElement("div");
117
+ parent.style.cssText = `height: ${parentHeight}px; outline: ${parentOutline}`;
118
+ // JSDOM has no layout; control the parent limit independently of CSS measurement.
119
+ Object.defineProperty(parent, "clientHeight", {
120
+ configurable: true,
121
+ value: parentHeight,
122
+ });
123
+ const panel = document.createElement("monster-panel");
124
+ // Set longhands explicitly: JSDOM does not expand the outline shorthand.
125
+ for (const [element, outline] of [
126
+ [panel, panelOutline],
127
+ [parent, parentOutline],
128
+ ]) {
129
+ const [width, style] = outline.split(" ");
130
+ element.style.outlineWidth = width;
131
+ element.style.outlineStyle = style;
132
+ }
133
+ parent.append(panel);
134
+ document.getElementById("mocks").append(parent);
135
+ panel.setOption("heightAdjustment", 8);
136
+ panel.getBoundingClientRect = () => ({ top: 120 });
137
+ Object.defineProperty(window, "innerHeight", {
138
+ configurable: true,
139
+ value: 720,
140
+ });
141
+ return { panel, parent };
142
+ };
143
+
144
+ for (const [panelOutline, parentOutline, expected] of [
145
+ ["3px none", "4px none", 608],
146
+ ["3px solid", "4px none", 605],
147
+ ["3px none", "4px dashed", 604],
148
+ ["3px solid", "4px dashed", 601],
149
+ ]) {
150
+ it(`allows only painted outlines (panel: ${panelOutline}, parent: ${parentOutline})`, () => {
151
+ const { panel } = mount({ panelOutline, parentOutline });
152
+ expect(panel.getMaximumHeight()).to.equal(expected);
153
+ expect(panel.recalculateHeight()).to.equal(panel);
154
+ expect(panel.style.height).to.equal(`${expected}px`);
155
+ });
156
+ }
157
+
158
+ it("still clamps to a smaller parent when outlines are not painted", () => {
159
+ const { panel } = mount({
160
+ panelOutline: "3px none",
161
+ parentOutline: "4px none",
162
+ parentHeight: 300,
163
+ });
164
+ expect(panel.getMaximumHeight()).to.equal(300);
165
+ panel.recalculateHeight();
166
+ expect(panel.style.height).to.equal("300px");
167
+ });
168
+
169
+ it("still reserves real parent borders, padding and margins", () => {
170
+ const { panel, parent } = mount({
171
+ panelOutline: "3px none",
172
+ parentOutline: "4px none",
173
+ });
174
+ parent.style.boxSizing = "content-box";
175
+ parent.style.borderBottom = "2px solid";
176
+ parent.style.paddingBottom = "6px";
177
+ parent.style.marginBottom = "4px";
178
+ expect(panel.getMaximumHeight()).to.equal(596);
179
+ });
180
+ });
96
181
  });
97
182
  });