From 944cb86276d3aed3c74e6cd3e7c8c0585abf7fb9 Mon Sep 17 00:00:00 2001 From: Evgeniya Date: Fri, 19 Nov 2021 10:56:58 +0300 Subject: [PATCH 1/3] FocusTrap: use Array.prototype.forEach.call() --- src/components/FocusTrap/FocusTrap.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/FocusTrap/FocusTrap.tsx b/src/components/FocusTrap/FocusTrap.tsx index 086e1b1867..192b30f0e9 100644 --- a/src/components/FocusTrap/FocusTrap.tsx +++ b/src/components/FocusTrap/FocusTrap.tsx @@ -54,14 +54,17 @@ export const FocusTrap: React.FC = ({ } const nodes: HTMLElement[] = []; - // eslint-disable-next-line no-restricted-properties - ref.current?.querySelectorAll(FOCUSABLE_ELEMENTS).forEach((focusableEl) => { - const { display, visibility } = window.getComputedStyle(focusableEl); - - if (display !== 'none' && visibility !== 'hidden') { - nodes.push(focusableEl as HTMLElement); - } - }); + Array.prototype.forEach.call( + // eslint-disable-next-line no-restricted-properties + ref.current.querySelectorAll(FOCUSABLE_ELEMENTS), + (focusableEl: Element) => { + const { display, visibility } = window.getComputedStyle(focusableEl); + + if (display !== 'none' && visibility !== 'hidden') { + nodes.push(focusableEl as HTMLElement); + } + }, + ); if (nodes?.length) { setFocusableNodes(nodes); From 4d04b0d4af9c7f980c97e344697de496cc0fccb3 Mon Sep 17 00:00:00 2001 From: Evgeniya Date: Fri, 19 Nov 2021 12:02:49 +0300 Subject: [PATCH 2/3] CardScroll: remove Array.from --- src/components/CardScroll/CardScroll.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/CardScroll/CardScroll.tsx b/src/components/CardScroll/CardScroll.tsx index ed42854ab1..78af2d738d 100644 --- a/src/components/CardScroll/CardScroll.tsx +++ b/src/components/CardScroll/CardScroll.tsx @@ -46,7 +46,10 @@ const CardScroll: React.FC = ({ children, size, sizeX, ...restP function getScrollToRight(offset: number): number { const containerWidth = refContainer.current.offsetWidth; - const slide = Array.from(refContainer.current.children).find((el: HTMLElement) => el.offsetLeft + el.offsetWidth - offset > containerWidth) as HTMLElement; + const slide = Array.prototype.find.call( + refContainer.current.children, + (el: HTMLElement) => el.offsetLeft + el.offsetWidth - offset > containerWidth, + ) as HTMLElement; if (!slide) { return offset; From 9f3212f3babb78f3659f051ee50742d20b64ec97 Mon Sep 17 00:00:00 2001 From: Evgeniya Date: Fri, 19 Nov 2021 12:04:48 +0300 Subject: [PATCH 3/3] useDraggable: use spread instead of Array.from --- src/components/Cell/useDraggable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Cell/useDraggable.tsx b/src/components/Cell/useDraggable.tsx index bae36ce58f..59e822beac 100644 --- a/src/components/Cell/useDraggable.tsx +++ b/src/components/Cell/useDraggable.tsx @@ -28,7 +28,7 @@ export const useDraggable = ({ onDragFinish }: Pick) setDragging(true); - const _siblings: HTMLElement[] = Array.from(rootEl.parentElement.childNodes); + const _siblings: HTMLElement[] = [...rootEl.parentElement.childNodes]; const idx = _siblings.indexOf(rootEl); setDragStartIndex(idx);