downshift 6.1.2-alpha.0 → 6.1.2
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/dist/downshift.cjs.js +6 -6
- package/dist/downshift.esm.js +6 -6
- package/dist/downshift.native.cjs.js +6 -6
- package/dist/downshift.umd.js +6 -6
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +1 -1
- package/dist/downshift.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/preact/dist/downshift.cjs.js +6 -6
- package/preact/dist/downshift.esm.js +6 -6
- package/preact/dist/downshift.umd.js +6 -6
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +1 -1
- package/preact/dist/downshift.umd.min.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "downshift",
|
|
3
|
-
"version": "6.1.2
|
|
3
|
+
"version": "6.1.2",
|
|
4
4
|
"description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.",
|
|
5
5
|
"main": "dist/downshift.cjs.js",
|
|
6
6
|
"react-native": "dist/downshift.native.cjs.js",
|
|
@@ -67,8 +67,8 @@ function scrollIntoView(node, menuNode) {
|
|
|
67
67
|
*/
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
function isOrContainsNode(parent, child
|
|
71
|
-
return parent === child || child instanceof
|
|
70
|
+
function isOrContainsNode(parent, child) {
|
|
71
|
+
return parent === child || child instanceof Node && parent.contains && parent.contains(child);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Simple debounce implementation. Will call the given
|
|
@@ -422,20 +422,20 @@ function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFr
|
|
|
422
422
|
*
|
|
423
423
|
* @param {EventTarget} target Target to check.
|
|
424
424
|
* @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
|
|
425
|
-
* @param {
|
|
425
|
+
* @param {Document} document The document.
|
|
426
426
|
* @param {boolean} checkActiveElement Whether to also check activeElement.
|
|
427
427
|
*
|
|
428
428
|
* @returns {boolean} Whether or not the target is within downshift elements.
|
|
429
429
|
*/
|
|
430
430
|
|
|
431
431
|
|
|
432
|
-
function targetWithinDownshift(target, downshiftElements,
|
|
432
|
+
function targetWithinDownshift(target, downshiftElements, document, checkActiveElement) {
|
|
433
433
|
if (checkActiveElement === void 0) {
|
|
434
434
|
checkActiveElement = true;
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
return downshiftElements.some(function (contextNode) {
|
|
438
|
-
return contextNode && (isOrContainsNode(contextNode, target
|
|
438
|
+
return contextNode && (isOrContainsNode(contextNode, target) || checkActiveElement && isOrContainsNode(contextNode, document.activeElement));
|
|
439
439
|
});
|
|
440
440
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
441
441
|
|
|
@@ -1976,7 +1976,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
1976
1976
|
|
|
1977
1977
|
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
1978
1978
|
return ref.current;
|
|
1979
|
-
}), environment)) {
|
|
1979
|
+
}), environment.document)) {
|
|
1980
1980
|
handleBlur();
|
|
1981
1981
|
}
|
|
1982
1982
|
};
|
|
@@ -54,8 +54,8 @@ function scrollIntoView(node, menuNode) {
|
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
function isOrContainsNode(parent, child
|
|
58
|
-
return parent === child || child instanceof
|
|
57
|
+
function isOrContainsNode(parent, child) {
|
|
58
|
+
return parent === child || child instanceof Node && parent.contains && parent.contains(child);
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Simple debounce implementation. Will call the given
|
|
@@ -409,20 +409,20 @@ function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFr
|
|
|
409
409
|
*
|
|
410
410
|
* @param {EventTarget} target Target to check.
|
|
411
411
|
* @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
|
|
412
|
-
* @param {
|
|
412
|
+
* @param {Document} document The document.
|
|
413
413
|
* @param {boolean} checkActiveElement Whether to also check activeElement.
|
|
414
414
|
*
|
|
415
415
|
* @returns {boolean} Whether or not the target is within downshift elements.
|
|
416
416
|
*/
|
|
417
417
|
|
|
418
418
|
|
|
419
|
-
function targetWithinDownshift(target, downshiftElements,
|
|
419
|
+
function targetWithinDownshift(target, downshiftElements, document, checkActiveElement) {
|
|
420
420
|
if (checkActiveElement === void 0) {
|
|
421
421
|
checkActiveElement = true;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
return downshiftElements.some(function (contextNode) {
|
|
425
|
-
return contextNode && (isOrContainsNode(contextNode, target
|
|
425
|
+
return contextNode && (isOrContainsNode(contextNode, target) || checkActiveElement && isOrContainsNode(contextNode, document.activeElement));
|
|
426
426
|
});
|
|
427
427
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
428
428
|
|
|
@@ -1963,7 +1963,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
1963
1963
|
|
|
1964
1964
|
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
1965
1965
|
return ref.current;
|
|
1966
|
-
}), environment)) {
|
|
1966
|
+
}), environment.document)) {
|
|
1967
1967
|
handleBlur();
|
|
1968
1968
|
}
|
|
1969
1969
|
};
|
|
@@ -474,8 +474,8 @@
|
|
|
474
474
|
*/
|
|
475
475
|
|
|
476
476
|
|
|
477
|
-
function isOrContainsNode(parent, child
|
|
478
|
-
return parent === child || child instanceof
|
|
477
|
+
function isOrContainsNode(parent, child) {
|
|
478
|
+
return parent === child || child instanceof Node && parent.contains && parent.contains(child);
|
|
479
479
|
}
|
|
480
480
|
/**
|
|
481
481
|
* Simple debounce implementation. Will call the given
|
|
@@ -829,20 +829,20 @@
|
|
|
829
829
|
*
|
|
830
830
|
* @param {EventTarget} target Target to check.
|
|
831
831
|
* @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
|
|
832
|
-
* @param {
|
|
832
|
+
* @param {Document} document The document.
|
|
833
833
|
* @param {boolean} checkActiveElement Whether to also check activeElement.
|
|
834
834
|
*
|
|
835
835
|
* @returns {boolean} Whether or not the target is within downshift elements.
|
|
836
836
|
*/
|
|
837
837
|
|
|
838
838
|
|
|
839
|
-
function targetWithinDownshift(target, downshiftElements,
|
|
839
|
+
function targetWithinDownshift(target, downshiftElements, document, checkActiveElement) {
|
|
840
840
|
if (checkActiveElement === void 0) {
|
|
841
841
|
checkActiveElement = true;
|
|
842
842
|
}
|
|
843
843
|
|
|
844
844
|
return downshiftElements.some(function (contextNode) {
|
|
845
|
-
return contextNode && (isOrContainsNode(contextNode, target
|
|
845
|
+
return contextNode && (isOrContainsNode(contextNode, target) || checkActiveElement && isOrContainsNode(contextNode, document.activeElement));
|
|
846
846
|
});
|
|
847
847
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
848
848
|
|
|
@@ -2373,7 +2373,7 @@
|
|
|
2373
2373
|
|
|
2374
2374
|
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
2375
2375
|
return ref.current;
|
|
2376
|
-
}), environment)) {
|
|
2376
|
+
}), environment.document)) {
|
|
2377
2377
|
handleBlur();
|
|
2378
2378
|
}
|
|
2379
2379
|
};
|