Skip to content

Commit

Permalink
fix: removed lodash.findlast to use JS code (carbon-design-system#18167)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidari authored Nov 27, 2024
1 parent 0da5e37 commit 29d0f18
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
Binary file not shown.
1 change: 0 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"flatpickr": "4.6.13",
"invariant": "^2.2.3",
"lodash.debounce": "^4.0.8",
"lodash.findlast": "^4.5.0",
"lodash.omit": "^4.5.0",
"lodash.throttle": "^4.1.1",
"prop-types": "^15.7.2",
Expand Down
8 changes: 3 additions & 5 deletions packages/react/src/internal/wrapFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import findLast from 'lodash.findlast';
import { useEffect } from 'react';
import {
DOCUMENT_POSITION_BROAD_PRECEDING,
Expand Down Expand Up @@ -62,10 +61,9 @@ function wrapFocus({
currentActiveNode === startTrapNode ||
comparisonResult & DOCUMENT_POSITION_BROAD_PRECEDING
) {
const tabbable = findLast(
bodyNode.querySelectorAll(selectorTabbable),
(elem) => Boolean(elem.offsetParent)
);
const tabbable = [...bodyNode.querySelectorAll(selectorTabbable)]
.reverse()
.find((elem) => Boolean(elem.offsetParent));
if (tabbable) {
tabbable.focus();
} else if (bodyNode !== oldActiveNode) {
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,6 @@ __metadata:
html-webpack-plugin: "npm:^5.5.0"
invariant: "npm:^2.2.3"
lodash.debounce: "npm:^4.0.8"
lodash.findlast: "npm:^4.5.0"
lodash.omit: "npm:^4.5.0"
lodash.throttle: "npm:^4.1.1"
mini-css-extract-plugin: "npm:^2.4.5"
Expand Down Expand Up @@ -18617,13 +18616,6 @@ __metadata:
languageName: node
linkType: hard

"lodash.findlast@npm:^4.5.0":
version: 4.6.0
resolution: "lodash.findlast@npm:4.6.0"
checksum: 10/ee7c3e6287ebab628b06449c8847aa00263f10b43bc67f1245e4b34c2edd80802148299f61e8577675790a05a4abe75ffdadacd0984a93724a69c7a01873fb1d
languageName: node
linkType: hard

"lodash.flatten@npm:^4.4.0":
version: 4.4.0
resolution: "lodash.flatten@npm:4.4.0"
Expand Down

0 comments on commit 29d0f18

Please sign in to comment.