Skip to content

Commit 29d0f18

Browse files
authored
fix: removed lodash.findlast to use JS code (#18167)
1 parent 0da5e37 commit 29d0f18

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed
-16.4 KB
Binary file not shown.

packages/react/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"flatpickr": "4.6.13",
6262
"invariant": "^2.2.3",
6363
"lodash.debounce": "^4.0.8",
64-
"lodash.findlast": "^4.5.0",
6564
"lodash.omit": "^4.5.0",
6665
"lodash.throttle": "^4.1.1",
6766
"prop-types": "^15.7.2",

packages/react/src/internal/wrapFocus.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import findLast from 'lodash.findlast';
98
import { useEffect } from 'react';
109
import {
1110
DOCUMENT_POSITION_BROAD_PRECEDING,
@@ -62,10 +61,9 @@ function wrapFocus({
6261
currentActiveNode === startTrapNode ||
6362
comparisonResult & DOCUMENT_POSITION_BROAD_PRECEDING
6463
) {
65-
const tabbable = findLast(
66-
bodyNode.querySelectorAll(selectorTabbable),
67-
(elem) => Boolean(elem.offsetParent)
68-
);
64+
const tabbable = [...bodyNode.querySelectorAll(selectorTabbable)]
65+
.reverse()
66+
.find((elem) => Boolean(elem.offsetParent));
6967
if (tabbable) {
7068
tabbable.focus();
7169
} else if (bodyNode !== oldActiveNode) {

yarn.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,6 @@ __metadata:
20312031
html-webpack-plugin: "npm:^5.5.0"
20322032
invariant: "npm:^2.2.3"
20332033
lodash.debounce: "npm:^4.0.8"
2034-
lodash.findlast: "npm:^4.5.0"
20352034
lodash.omit: "npm:^4.5.0"
20362035
lodash.throttle: "npm:^4.1.1"
20372036
mini-css-extract-plugin: "npm:^2.4.5"
@@ -18617,13 +18616,6 @@ __metadata:
1861718616
languageName: node
1861818617
linkType: hard
1861918618

18620-
"lodash.findlast@npm:^4.5.0":
18621-
version: 4.6.0
18622-
resolution: "lodash.findlast@npm:4.6.0"
18623-
checksum: 10/ee7c3e6287ebab628b06449c8847aa00263f10b43bc67f1245e4b34c2edd80802148299f61e8577675790a05a4abe75ffdadacd0984a93724a69c7a01873fb1d
18624-
languageName: node
18625-
linkType: hard
18626-
1862718619
"lodash.flatten@npm:^4.4.0":
1862818620
version: 4.4.0
1862918621
resolution: "lodash.flatten@npm:4.4.0"

0 commit comments

Comments
 (0)