entasis 0.10.0 → 0.10.1

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.
@@ -49,7 +49,8 @@ export type SelectAlignment = {
49
49
  * Item-aligned placement, the native select's and Radix's: the panel covers the trigger with the
50
50
  * option's middle on the trigger's middle and its text on the value text. A panel that would cross
51
51
  * the top edge is pinned there and its list scrolled by the overflow, so the option stays on the
52
- * trigger; one that would cross the bottom edge is cut short and scrolls. Only when the trigger
53
- * sits so low that fewer than four rows would fit does the panel rise and give up the alignment.
52
+ * trigger; one that would cross the bottom edge is cut short and scrolls. When either leaves fewer
53
+ * than four rows, the panel gives up the alignment and grows to four: up from the bottom edge for a
54
+ * trigger sitting low, down from the top edge for a short list pinned there.
54
55
  */
55
56
  export declare function alignItemWithTrigger(m: SelectAlignMetrics): SelectAlignment;
@@ -5,8 +5,9 @@ const clamp = (value, min, max) => Math.min(Math.max(value, min), Math.max(min,
5
5
  * Item-aligned placement, the native select's and Radix's: the panel covers the trigger with the
6
6
  * option's middle on the trigger's middle and its text on the value text. A panel that would cross
7
7
  * the top edge is pinned there and its list scrolled by the overflow, so the option stays on the
8
- * trigger; one that would cross the bottom edge is cut short and scrolls. Only when the trigger
9
- * sits so low that fewer than four rows would fit does the panel rise and give up the alignment.
8
+ * trigger; one that would cross the bottom edge is cut short and scrolls. When either leaves fewer
9
+ * than four rows, the panel gives up the alignment and grows to four: up from the bottom edge for a
10
+ * trigger sitting low, down from the top edge for a short list pinned there.
10
11
  */
11
12
  export function alignItemWithTrigger(m) {
12
13
  const top = SELECT_ALIGN_MARGIN;
@@ -22,10 +23,16 @@ export function alignItemWithTrigger(m) {
22
23
  y = top;
23
24
  }
24
25
  let height = Math.min(m.panel.height - scrollTop, bottom - y);
25
- const minHeight = Math.min(m.panel.height, chromeAbove + chromeBelow + m.item.height * 4);
26
+ const fourRows = chromeAbove + chromeBelow + m.item.height * 4;
27
+ // A list less than a row taller than four rows (its own padding) opens whole: cutting it would
28
+ // scroll it a few pixels and show a scroll arrow for nothing.
29
+ const minHeight = m.panel.height - fourRows < m.item.height ? m.panel.height : fourRows;
26
30
  if (height < minHeight) {
31
+ // Grow away from the edge that is not in the way. A panel cut by the bottom edge rises; one
32
+ // pinned at the top (the last options of a short list under a high trigger, where the pin's
33
+ // scroll leaves too few rows) grows down and scrolls back instead of dropping to the bottom.
27
34
  height = minHeight;
28
- y = Math.max(top, bottom - height);
35
+ y = Math.max(top, Math.min(y, bottom - height));
29
36
  }
30
37
  const listHeight = Math.max(0, height - chromeAbove - chromeBelow);
31
38
  scrollTop = clamp(scrollTop, 0, m.list.height - listHeight);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "entasis",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",