diff --git a/superset-frontend/src/dashboard/components/gridComponents/Row.jsx b/superset-frontend/src/dashboard/components/gridComponents/Row.jsx index a353d85c3b4e5c9c3861948c8790f9a7e526d7cf..1025e4101d41b69e40821685d4ae8bb09c3d055a 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Row.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Row.jsx @@ -51,6 +51,7 @@ import WithPopoverMenu from 'src/dashboard/components/menu/WithPopoverMenu'; import { componentShape } from 'src/dashboard/util/propShapes'; import backgroundStyleOptions from 'src/dashboard/util/backgroundStyleOptions'; import { BACKGROUND_TRANSPARENT } from 'src/dashboard/util/constants'; +import { isEmbedded } from 'src/dashboard/util/isEmbedded'; import { EMPTY_CONTAINER_Z_INDEX } from 'src/dashboard/constants'; import { isCurrentUserBot } from 'src/utils/isBot'; import { useDebouncedEffect } from '../../../explore/exploreUtils'; @@ -188,7 +189,10 @@ const Row = props => { observerDisabler = new IntersectionObserver( ([entry]) => { if (!entry.isIntersecting && isComponentVisibleRef.current) { - setIsInView(false); + // Reference: https://www.w3.org/TR/intersection-observer/#dom-intersectionobserver-rootmargin + if (!isEmbedded()) { + setIsInView(false); + } } }, { diff --git a/superset-frontend/src/dashboard/util/isEmbedded.ts b/superset-frontend/src/dashboard/util/isEmbedded.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c8d30fcce33e45fd2138ffcd700b0d95283a4ed --- /dev/null +++ b/superset-frontend/src/dashboard/util/isEmbedded.ts @@ -0,0 +1,26 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export const isEmbedded = () => { + try { + return window.self !== window.top || window.frameElement !== null; + } catch (e) { + return true; + } +};