You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2025/05/23 12:48:57 UTC
(superset) 01/08: fix(Row): don't unload charts while embedded to reduce rerenders (#33422)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 5.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit cd12f30db2ceb7b8113d3a6fafad6d79ac7afd4b
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Tue May 13 16:32:39 2025 +0300
fix(Row): don't unload charts while embedded to reduce rerenders (#33422)
(cherry picked from commit 21ca26acd72bde50cb75c3daa8ba328054944f6f)
---
.../dashboard/components/gridComponents/Row.jsx | 6 ++++-
superset-frontend/src/dashboard/util/isEmbedded.ts | 26 ++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Row.jsx b/superset-frontend/src/dashboard/components/gridComponents/Row.jsx
index bd59306ca9..23cf2d45a4 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 0000000000..3c8d30fcce
--- /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;
+ }
+};