From 754a73f9f4600dbac12405a255aea4582103bb37 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Tue, 25 Feb 2020 01:37:12 +0900 Subject: [PATCH] Fix ie11 fill (#1018) * Fix for 'update' of null error in Sentry We were trying to update Perfect Scrollbar after 400ms timeout. If the was user already left the page it caused an error. Now we only update it if the ref to perfect scrollbar is sill present on page after timeout. See: https://sentry.io/organizations/iterative/issues/1529236771/ https://sentry.io/organizations/iterative/issues/1525523962/ And others like that. * Replace Array.fill with lodash to support IE11 Another Sentry error https://sentry.io/organizations/iterative/issues/1521458935/ --- package.json | 1 + src/components/Community/Events/index.js | 3 ++- src/components/Documentation/SidebarMenu/index.js | 8 +++++--- yarn.lock | 5 +++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f2768f9108..e4781f8558 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "dom-scroll-into-view": "^2.0.1", "github-markdown-css": "^3.0.1", "isomorphic-fetch": "^2.2.1", + "lodash.fill": "^3.4.0", "lodash.includes": "^4.3.0", "lodash.kebabcase": "^4.1.1", "lodash.startcase": "^4.4.0", diff --git a/src/components/Community/Events/index.js b/src/components/Community/Events/index.js index 5f90be6b0f..c63900ecf0 100644 --- a/src/components/Community/Events/index.js +++ b/src/components/Community/Events/index.js @@ -1,6 +1,7 @@ import React, { useCallback } from 'react' import PropTypes from 'prop-types' import format from 'date-fns/format' +import fill from 'lodash.fill' import { logEvent } from '../../../utils/ga' @@ -18,7 +19,7 @@ const { description, mobileDescription, title } = data.section.events const { events } = data const modifiedEvents = events.length > 3 ? events.slice(0, 3) : events -const eventPlaceholders = new Array(3 - modifiedEvents.length).fill(Item) +const eventPlaceholders = fill(new Array(3 - modifiedEvents.length), Item) function CommunityEvent({ theme, diff --git a/src/components/Documentation/SidebarMenu/index.js b/src/components/Documentation/SidebarMenu/index.js index 2e6f0edef3..cb1ead6601 100644 --- a/src/components/Documentation/SidebarMenu/index.js +++ b/src/components/Documentation/SidebarMenu/index.js @@ -76,9 +76,11 @@ export default function SidebarMenu({ id, sidebar, currentPath, onClick }) { setIsScrollHidden(true) setTimeout(() => { - psRef.current.update() - scrollIntoView(node, parent, { onlyScrollIfNeeded: true }) - setIsScrollHidden(false) + if (psRef.current) { + psRef.current.update() + scrollIntoView(node, parent, { onlyScrollIfNeeded: true }) + setIsScrollHidden(false) + } }, 400) return () => { diff --git a/yarn.lock b/yarn.lock index 029b09536f..5ce8e1db69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5572,6 +5572,11 @@ lodash.debounce@^4.0.8: resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= +lodash.fill@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/lodash.fill/-/lodash.fill-3.4.0.tgz#a3c74ae640d053adf0dc2079f8720788e8bfef85" + integrity sha1-o8dK5kDQU63w3CB5+HIHiOi/74U= + lodash.includes@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f"