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(dashboard): Prevent char overflow when displaying chart description #14467

Merged

Conversation

m-ajay
Copy link
Contributor

@m-ajay m-ajay commented May 4, 2021

SUMMARY

Fixes #12643

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before
screenshot-before
After
Screen Shot 2021-05-04 at 2 02 42 PM

TEST PLAN

CI and manual test

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

@m-ajay m-ajay changed the title [WIP] fix(dashboard): Prevent char overflow when displaying chart description fix(dashboard): Prevent char overflow when displaying chart description May 4, 2021
@codecov
Copy link

codecov bot commented May 4, 2021

Codecov Report

Merging #14467 (34a4fa1) into master (21cf12a) will decrease coverage by 0.00%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14467      +/-   ##
==========================================
- Coverage   77.12%   77.12%   -0.01%     
==========================================
  Files         954      953       -1     
  Lines       48175    48176       +1     
  Branches     6063     6053      -10     
==========================================
  Hits        37155    37155              
- Misses      10819    10820       +1     
  Partials      201      201              
Flag Coverage Δ
javascript 71.95% <88.88%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
.../src/dashboard/components/gridComponents/Chart.jsx 81.18% <88.88%> (+1.80%) ⬆️
...rc/views/CRUD/alert/components/AlertStatusIcon.tsx 46.96% <0.00%> (-0.80%) ⬇️
...ols/MetricControl/AdhocMetricEditPopover/index.jsx 78.29% <0.00%> (-0.50%) ⬇️
superset-frontend/src/chart/chartAction.js 52.70% <0.00%> (-0.27%) ⬇️
superset-frontend/src/components/Select/styles.tsx 84.72% <0.00%> (-0.21%) ⬇️
...onfigModal/FiltersConfigForm/FiltersConfigForm.tsx 70.23% <0.00%> (-0.18%) ⬇️
superset-frontend/src/components/Icons/Icon.tsx 96.00% <0.00%> (ø)
superset-frontend/src/components/Label/index.tsx 100.00% <0.00%> (ø)
...uperset-frontend/src/explore/exploreUtils/index.js 66.25% <0.00%> (ø)
...set-frontend/src/components/ListViewCard/index.tsx 100.00% <0.00%> (ø)
... and 21 more

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 21cf12a...34a4fa1. Read the comment docs.

// fix for https://github.com/apache/superset/issues/12643
if (prevProps.isExpanded !== this.props.isExpanded) {
this.forceUpdate();
}
Copy link

Choose a reason for hiding this comment

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

forceUpdate() is a solution but we should try to avoid all uses of forceUpdate() and only read from this.props and this.state in render().

So i suggest we do this:

  • add descriptionHeight in component state, initial value = 0
  • add componentDidUpdate so that we can set descriptionHeight state whenever isExpanded prop is changed:
  componentDidUpdate(prevProps, prevState, snapshot) {
    if (this.props.isExpanded !== prevProps.isExpanded) {
      const descriptionHeight =
        this.props.isExpanded && this.descriptionRef
          ? this.descriptionRef.offsetHeight
          : 0;

      this.setState({
        descriptionHeight,
      })
    }
  }
  • in shouldComponentUpdate, if descriptionHeight state is changed, just like height state is change, should return true:
if (
      nextState.width !== this.state.width ||
      nextState.height !== this.state.height ||
      nextState.descriptionHeight !== this.state.descriptionHeight
    ) {
      return true;
    }
  • in the end, getChartHeight() function should return chart content height by height and descriptionHeight:
  getChartHeight() {
    const headerHeight = this.getHeaderHeight();
    return this.state.height - headerHeight - this.state.descriptionHeight;
  }

@junlincc
Copy link
Member

junlincc commented May 4, 2021

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2021

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

@michael-s-molina
Copy link
Member

@m-ajay Can you change the PR description from "This fixes issue #12643" to "Fixes #12643" so that the issue is automatically closed when we merge this PR?

Copy link

@graceguo-supercat graceguo-supercat left a comment

Choose a reason for hiding this comment

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

LGTM

@graceguo-supercat graceguo-supercat merged commit c832542 into apache:master May 5, 2021
@graceguo-supercat
Copy link

giphy

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2021

Ephemeral environment shutdown and build artifacts deleted.

cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
…on (apache#14467)

* Force refresh the chart on toggle display description

* Use forceUpdate instead of forceRefresh

* Instead of forceUpdate, add a state for desciption height

Co-authored-by: Ajay Mancheery <ajaymancheery@Ajays-MacBook-Pro.local>
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
…on (apache#14467)

* Force refresh the chart on toggle display description

* Use forceUpdate instead of forceRefresh

* Instead of forceUpdate, add a state for desciption height

Co-authored-by: Ajay Mancheery <ajaymancheery@Ajays-MacBook-Pro.local>
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
…on (apache#14467)

* Force refresh the chart on toggle display description

* Use forceUpdate instead of forceRefresh

* Instead of forceUpdate, add a state for desciption height

Co-authored-by: Ajay Mancheery <ajaymancheery@Ajays-MacBook-Pro.local>
@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 size/S 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[dashboard] Toggle Chart Description results in chart overflowing it's area
5 participants