Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix adhocpopovers tab animate. #14478

Merged
merged 10 commits into from
May 14, 2021
Merged

Conversation

pkdotson
Copy link
Member

@pkdotson pkdotson commented May 5, 2021

SUMMARY

The tab component within the adhocFilterEditpopvers were showing an animated view within the tab when user clicks on new tabs. This pr removes the default animate to false

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

before
https://user-images.githubusercontent.com/17326228/117086414-4a6a8700-ad01-11eb-9a1c-6f29b20c2d9c.mov

after

Screen.Recording.2021-05-04.at.5.43.01.PM.mov

TEST PLAN

Go to chart and open the popovers to ensure they do not animate when new tab is clicked.

ADDITIONAL INFORMATION

  • [ x] Has associated issue: [Explore] Tab Animation on Metric popover flies out of the box #14475
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@ktmud
Copy link
Member

ktmud commented May 5, 2021

Could we disable the animation globally by default? E.g. like this:

diff --git a/superset-frontend/src/components/Tabs/Tabs.tsx b/superset-frontend/src/components/Tabs/Tabs.tsx
index 90c3a64e6..f016b73f3 100644
--- a/superset-frontend/src/components/Tabs/Tabs.tsx
+++ b/superset-frontend/src/components/Tabs/Tabs.tsx
@@ -20,81 +20,92 @@ import React from 'react';
 import { css, styled } from '@superset-ui/core';
 import AntDTabs, { TabsProps as AntDTabsProps } from 'antd/lib/tabs';
 import Icon from 'src/components/Icon';
+import { useTheme } from '@emotion/react';
 
 export interface TabsProps extends AntDTabsProps {
   fullWidth?: boolean;
   allowOverflow?: boolean;
 }
 
-const notForwardedProps = ['fullWidth', 'allowOverflow'];
+const StyledTabs = ({
+  animated = false,
+  fullWidth = true,
+  allowOverflow = true,
+  ...props
+}: TabsProps) => {
+  const theme = useTheme();
+  return (
+    <AntDTabs
+      animated={animated}
+      {...props}
+      css={css`
+        overflow: ${allowOverflow ? 'visible' : 'hidden'};
+
+        .ant-tabs-content-holder {
+          overflow: ${allowOverflow ? 'visible' : 'auto'};
+        }
 
-const StyledTabs = styled(AntDTabs, {
-  shouldForwardProp: prop => !notForwardedProps.includes(String(prop)),
-})<TabsProps>`
-  overflow: ${({ allowOverflow }) => (allowOverflow ? 'visible' : 'hidden')};
+        .ant-tabs-tab {
+          flex: 1 1 auto;
 
-  .ant-tabs-content-holder {
-    overflow: ${({ allowOverflow }) => (allowOverflow ? 'visible' : 'auto')};
-  }
+          &.ant-tabs-tab-active .ant-tabs-tab-btn {
+            color: inherit;
+          }
 
-  .ant-tabs-tab {
-    flex: 1 1 auto;
+          &:hover {
+            .anchor-link-container {
+              cursor: pointer;
 
-    &.ant-tabs-tab-active .ant-tabs-tab-btn {
-      color: inherit;
-    }
+              .fa.fa-link {
+                visibility: visible;
+              }
+            }
+          }
 
-    &:hover {
-      .anchor-link-container {
-        cursor: pointer;
+          .short-link-trigger.btn {
+            padding: 0 ${theme.gridUnit}px;
 
-        .fa.fa-link {
-          visibility: visible;
+            & > .fa.fa-link {
+              top: 0;
+            }
+          }
         }
-      }
-    }
-
-    .short-link-trigger.btn {
-      padding: 0 ${({ theme }) => theme.gridUnit}px;
-
-      & > .fa.fa-link {
-        top: 0;
-      }
-    }
-  }
-
-  ${({ fullWidth }) =>
-    fullWidth &&
-    css`
-      .ant-tabs-nav-list {
-        width: 100%;
-      }
-
-      .ant-tabs-tab {
-        width: 0;
-      }
-    `};
 
-  .ant-tabs-tab-btn {
-    display: flex;
-    flex: 1 1 auto;
-    align-items: center;
-    justify-content: center;
-    font-size: ${({ theme }) => theme.typography.sizes.s}px;
-    text-align: center;
-    text-transform: uppercase;
-    user-select: none;
-
-    .required {
-      margin-left: ${({ theme }) => theme.gridUnit / 2}px;
-      color: ${({ theme }) => theme.colors.error.base};
-    }
-  }
+        ${fullWidth &&
+        css`
+          .ant-tabs-nav-list {
+            width: 100%;
+          }
+
+          .ant-tabs-tab {
+            width: 0;
+            margin-right: 0;
+          }
+        `};
+
+        .ant-tabs-tab-btn {
+          display: flex;
+          flex: 1 1 auto;
+          align-items: center;
+          justify-content: center;
+          font-size: ${theme.typography.sizes.s}px;
+          text-align: center;
+          text-transform: uppercase;
+          user-select: none;
+
+          .required {
+            margin-left: ${theme.gridUnit / 2}px;
+            color: ${theme.colors.error.base};
+          }
+        }
 
-  .ant-tabs-ink-bar {
-    background: ${({ theme }) => theme.colors.secondary.base};
-  }
-`;
+        .ant-tabs-ink-bar {
+          background: ${theme.colors.secondary.base};
+        }
+      `}
+    />
+  );
+};
 
 const StyledTabPane = styled(AntDTabs.TabPane)``;
 
@@ -102,11 +113,6 @@ const Tabs = Object.assign(StyledTabs, {
   TabPane: StyledTabPane,
 });
 
-Tabs.defaultProps = {
-  fullWidth: true,
-  animated: true,
-};
-
 const StyledEditableTabs = styled(StyledTabs)`
   .ant-tabs-content-holder {
     background: white;

Note this diff also fixes a bug where tabs are not expanded to full width:

Before

Xnip2021-05-04_19-20-51

After

Xnip2021-05-04_19-20-18

@junlincc
Copy link
Member

junlincc commented May 5, 2021

@pkdotson Thanks for the quick fix, let get the check pass!

@ktmud we need a good case to make that change. and even so, probably not in this PR.

@codecov
Copy link

codecov bot commented May 5, 2021

Codecov Report

Merging #14478 (be8e392) into master (e4d2424) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head be8e392 differs from pull request most recent head 47cfb53. Consider uploading reports for the commit 47cfb53 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14478      +/-   ##
==========================================
- Coverage   77.47%   77.47%   -0.01%     
==========================================
  Files         958      958              
  Lines       48486    48483       -3     
  Branches     5679     5683       +4     
==========================================
- Hits        37565    37562       -3     
  Misses      10721    10721              
  Partials      200      200              
Flag Coverage Δ
javascript 72.51% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...components/DashboardBuilder/DashboardContainer.tsx 100.00% <ø> (ø)
superset-frontend/src/components/Tabs/Tabs.tsx 96.55% <100.00%> (-0.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e4d2424...47cfb53. Read the comment docs.

@ktmud
Copy link
Member

ktmud commented May 5, 2021

what's the good case for keeping animation on as default? Note this change would not prevent us from turning on the animation when needed. And if we do consciously decide we want animation in the future, it's literally just a flip of a switch.

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pull-request-size pull-request-size bot added size/M and removed size/XS labels May 6, 2021
@pull-request-size pull-request-size bot added size/L and removed size/M labels May 6, 2021
Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! with minor suggestions.

@rusackas
Copy link
Member

rusackas commented May 8, 2021

@pkdotson please rebase.

Also for the thread convo, I agree with the disabling of this particular animation by default is a fine idea. We can enable it for any use cases where it makes sense.

See also #14496, which does exactly that.

@rusackas
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@rusackas Ephemeral environment spinning up at http://35.165.160.43:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@rusackas rusackas added the bash! label May 12, 2021
@rusackas
Copy link
Member

@pkdotson please rebase, I think this is otherwise good to go.

@pkdotson pkdotson merged commit e4e23ea into apache:master May 14, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@geido geido mentioned this pull request May 26, 2021
8 tasks
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* fix popover

* addd tabs default css

* fix lint

* fix tests

* address comments

* lint fix

* fix test

* lint
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* fix popover

* addd tabs default css

* fix lint

* fix tests

* address comments

* lint fix

* fix test

* lint
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* fix popover

* addd tabs default css

* fix lint

* fix tests

* address comments

* lint fix

* fix test

* lint
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels explore:metrics Related to metrics of Explore preset-io size/L 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants