@xeplr/ui-table 1.1.5 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeplr/ui-table",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Controlled TanStack Table wrapper with auto-detected column types and smart filters",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -15,8 +15,9 @@ import { createPortal } from 'react-dom';
15
15
  * cannot read is a filter you cannot use.
16
16
  *
17
17
  * A portal has no ancestors to be clipped by. The cost is that it no longer
18
- * moves with the page on its own, so it closes on scroll and resize rather
19
- * than hanging in the wrong place.
18
+ * moves with the page on its own, so a scroll of the page or the table moves
19
+ * it after its trigger (and closes it once the trigger is out of view); a
20
+ * scroll INSIDE the panel — its own list of values — is just reading it.
20
21
  *
21
22
  * @param {object} props
22
23
  * @param {boolean} props.isActive - Whether filter is currently applied
@@ -60,19 +61,29 @@ export default function FilterWrapper({ isActive, children, onClear }) {
60
61
  var inPanel = panelRef.current && panelRef.current.contains(e.target);
61
62
  if (!inTrigger && !inPanel) setOpen(false);
62
63
  }
63
- // A portalled panel does not travel with what it is anchored to, so
64
- // rather than let it hang somewhere wrong it closes. `true` catches
65
- // scrolling in the TABLE, not just the window — the scroll event does not
66
- // bubble, so a listener without capture never hears it.
67
- function handleScroll() { setOpen(false); }
64
+ // A portalled panel does not travel with what it is anchored to, so a
65
+ // scroll moves it after its trigger. `true` catches scrolling in the
66
+ // TABLE, not just the window — the scroll event does not bubble, so a
67
+ // listener without capture never hears it. Scrolling the panel's own list
68
+ // is not a reason to move or close it: it used to close the panel the
69
+ // moment anyone scrolled down its values.
70
+ function handleScroll(e) {
71
+ if (panelRef.current && e && e.target instanceof Node && panelRef.current.contains(e.target)) return;
72
+ var el = wrapperRef.current;
73
+ if (!el) return;
74
+ var r = el.getBoundingClientRect();
75
+ // The trigger scrolled out of view: nothing left to hang from.
76
+ if (r.bottom < 0 || r.top > window.innerHeight || r.right < 0 || r.left > window.innerWidth) { setOpen(false); return; }
77
+ place();
78
+ }
68
79
 
69
80
  document.addEventListener('mousedown', handleClick);
70
81
  window.addEventListener('scroll', handleScroll, true);
71
- window.addEventListener('resize', handleScroll);
82
+ window.addEventListener('resize', place);
72
83
  return function() {
73
84
  document.removeEventListener('mousedown', handleClick);
74
85
  window.removeEventListener('scroll', handleScroll, true);
75
- window.removeEventListener('resize', handleScroll);
86
+ window.removeEventListener('resize', place);
76
87
  };
77
88
  }, [open, place]);
78
89