@allurereport/web-commons 3.10.0 → 3.11.0

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.
@@ -35,14 +35,31 @@ export const scrollTreeFocusIntoView = (target, scrollRoot, kind, inset = 4) =>
35
35
  const rootRect = scrollRoot.getBoundingClientRect();
36
36
  const delta = computeTreeFocusScrollDelta(nodeRect, rootRect, kind, inset);
37
37
  if (Math.abs(delta) > 1) {
38
- scrollRoot.scrollTop += delta;
38
+ const pinToTop = kind === "group" || kind === "env";
39
+ if (pinToTop) {
40
+ const contentY = nodeRect.top - rootRect.top + scrollRoot.scrollTop;
41
+ scrollRoot.scrollTop = Math.max(0, contentY - inset);
42
+ }
43
+ else {
44
+ scrollRoot.scrollTop += delta;
45
+ }
46
+ }
47
+ };
48
+ const computeStickyInset = (scrollRoot, baseInset) => {
49
+ let total = baseInset;
50
+ for (const el of Array.from(scrollRoot.querySelectorAll("[data-tree-sticky-header]"))) {
51
+ if (el instanceof HTMLElement) {
52
+ total += el.offsetHeight;
53
+ }
39
54
  }
55
+ return total;
40
56
  };
41
57
  export const scrollFocusIntoView = (target, options) => {
42
58
  const containerAttribute = options?.containerAttribute ?? "data-tree-scroll-container";
43
59
  const scrollRoot = findFocusScrollRoot(target, containerAttribute);
44
60
  if (scrollRoot) {
45
- scrollTreeFocusIntoView(target, scrollRoot, options?.kind, options?.inset);
61
+ const inset = computeStickyInset(scrollRoot, options?.inset ?? 4);
62
+ scrollTreeFocusIntoView(target, scrollRoot, options?.kind, inset);
46
63
  return;
47
64
  }
48
65
  target.scrollIntoView({ block: "center", inline: "nearest" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/web-commons",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Collection of utilities used across the web Allure reports",
5
5
  "keywords": [
6
6
  "allure",
@@ -26,10 +26,10 @@
26
26
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
27
27
  },
28
28
  "dependencies": {
29
- "@allurereport/aql": "3.10.0",
30
- "@allurereport/charts-api": "3.10.0",
31
- "@allurereport/core-api": "3.10.0",
32
- "@allurereport/plugin-api": "3.10.0",
29
+ "@allurereport/aql": "3.11.0",
30
+ "@allurereport/charts-api": "3.11.0",
31
+ "@allurereport/core-api": "3.11.0",
32
+ "@allurereport/plugin-api": "3.11.0",
33
33
  "@preact/signals": "^2.6.1",
34
34
  "@preact/signals-core": "^1.12.2",
35
35
  "ansi-to-html": "^0.7.2",