mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(Row): don't unload charts while embedded to reduce rerenders (#33422)
(cherry picked from commit 21ca26acd7)
This commit is contained in:
committed by
Michael Molina
parent
602208d68a
commit
cd12f30db2
@@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
26
superset-frontend/src/dashboard/util/isEmbedded.ts
Normal file
26
superset-frontend/src/dashboard/util/isEmbedded.ts
Normal file
@@ -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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user