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(charts): Table Chart doesn't twitch when resizing #20833

Merged
merged 1 commit into from
Jul 27, 2022

Conversation

Antonio-RiveroMartnez
Copy link
Member

SUMMARY

The problem is that when the table is rendering our useResizeDetector triggers changes to hide the scrollbar if necessary which causes that width and height from props are always changing and the component enters into an infinite loop. We are detecting the changes and applying the resize only if the new difference (any) is not related to the scrollbar size.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
error

After:
test

TESTING INSTRUCTIONS

  1. Visit the "Charts" page and hit "+chart" button
  2. Select "Flights" as dataset and "Table" as viz type
  3. Toggle to "Raw Records" in query mode
  4. Select ORIGIN_AIRPORT and DAY_OF_WEEK for Columns
  5. Select AIRLINE[asc] for ordering
  6. Create chart

Expected results:

  1. The table isn't twitching

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • [] 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

- Handle resize properly when only the scrollbar is changing so it doesn't get stuck into an infinite loop.
@codecov
Copy link

codecov bot commented Jul 22, 2022

Codecov Report

Merging #20833 (55421cd) into master (f011aba) will increase coverage by 0.01%.
The diff coverage is 84.61%.

@@            Coverage Diff             @@
##           master   #20833      +/-   ##
==========================================
+ Coverage   66.34%   66.35%   +0.01%     
==========================================
  Files        1756     1756              
  Lines       66747    66769      +22     
  Branches     7059     7064       +5     
==========================================
+ Hits        44282    44306      +24     
+ Misses      20667    20663       -4     
- Partials     1798     1800       +2     
Flag Coverage Δ
javascript 52.01% <84.61%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
...tend/plugins/plugin-chart-table/src/TableChart.tsx 41.91% <84.61%> (+3.60%) ⬆️
...frontend/src/SqlLab/components/ResultSet/index.tsx 51.74% <0.00%> (-2.33%) ⬇️
...tend/src/explore/components/controls/ViewQuery.tsx 72.72% <0.00%> (ø)
...src/explore/components/controls/ViewQueryModal.tsx 75.00% <0.00%> (+1.08%) ⬆️
...hart-table/src/DataTable/utils/getScrollBarSize.ts 85.71% <0.00%> (+78.57%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.


useLayoutEffect(() => {
// After initial load the table should resize only when the new sizes
// Are not only scrollbar updates, otherwise, the table would twicth
Copy link
Member

Choose a reason for hiding this comment

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

Appreciate the comments! This helps SOOOO much.

@rusackas rusackas merged commit 234c446 into apache:master Jul 27, 2022
@Antonio-RiveroMartnez Antonio-RiveroMartnez deleted the FIX-51084 branch August 2, 2022 21:15
@lilykuang lilykuang added the v2.0 label Feb 23, 2023
lilykuang pushed a commit to preset-io/superset that referenced this pull request Feb 23, 2023
- Handle resize properly when only the scrollbar is changing so it doesn't get stuck into an infinite loop.

(cherry picked from commit 234c446)
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 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/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants