@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
|
@@ -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
|
|
19
|
-
*
|
|
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
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
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',
|
|
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',
|
|
86
|
+
window.removeEventListener('resize', place);
|
|
76
87
|
};
|
|
77
88
|
}, [open, place]);
|
|
78
89
|
|