@johly/bits-ui 2.18.5 → 2.18.8

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.
@@ -80,6 +80,21 @@
80
80
  measureFrame = null;
81
81
  }
82
82
 
83
+ function getNearestScrollableAncestor(target: HTMLElement, boundary: HTMLElement) {
84
+ let node: HTMLElement | null = target.parentElement;
85
+ while (node && boundary.contains(node)) {
86
+ if (node.scrollHeight - node.clientHeight > 1) {
87
+ const overflowY = node.ownerDocument.defaultView?.getComputedStyle(node).overflowY;
88
+ if (overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay") {
89
+ return node;
90
+ }
91
+ }
92
+ if (node === boundary) break;
93
+ node = node.parentElement;
94
+ }
95
+ return null;
96
+ }
97
+
83
98
  function measureListAlign() {
84
99
  measureFrame = null;
85
100
  if (align !== "list" || (side !== "right" && side !== "left")) {
@@ -101,7 +116,8 @@
101
116
  return;
102
117
  }
103
118
  const rowRect = firstRow.getBoundingClientRect();
104
- listAlignOffset = Math.round(contentRect.top - rowRect.top);
119
+ const scroller = getNearestScrollableAncestor(firstRow, contentNode);
120
+ listAlignOffset = Math.round(contentRect.top - rowRect.top - (scroller?.scrollTop ?? 0));
105
121
  }
106
122
 
107
123
  function queueMeasureListAlign() {
@@ -108,6 +108,9 @@ export class FloatingContentState {
108
108
  : undefined,
109
109
  ...this.detectOverflowOptions,
110
110
  }),
111
+ this.opts.avoidCollisions.current &&
112
+ this.#collisionAvoidance.side === "flip" &&
113
+ flip({ ...this.detectOverflowOptions }),
111
114
  this.opts.avoidCollisions.current &&
112
115
  this.#collisionAvoidance.side === "flip" &&
113
116
  shift({
@@ -116,9 +119,6 @@ export class FloatingContentState {
116
119
  limiter: this.opts.sticky.current === "partial" ? limitShift() : undefined,
117
120
  ...this.detectOverflowOptions,
118
121
  }),
119
- this.opts.avoidCollisions.current &&
120
- this.#collisionAvoidance.side === "flip" &&
121
- flip({ ...this.detectOverflowOptions }),
122
122
  size({
123
123
  ...this.detectOverflowOptions,
124
124
  apply: ({ rects, availableWidth, availableHeight }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johly/bits-ui",
3
- "version": "2.18.5",
3
+ "version": "2.18.8",
4
4
  "license": "MIT",
5
5
  "repository": "github:johanohly/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",