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(native-filters): improve loading styles for filter component #13794

Merged
merged 3 commits into from Mar 29, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented Mar 25, 2021

SUMMARY

Currently the native filter components render irregularly when waiting for data to be returned from the database, causing unnecessary zigzagging on the filter tab. In addition, the default value selector in the filter config modal doesn't have a spinner to indicate that data is loading.

AFTER

Now the minimum size of the filter item is at minimum the same height as the AntD select component, leading to a more peaceful loading experience. Also note smaller spinner:
filtertab-after

When data is being fetched from the backend in the filter config modal, the spinner is activated:
defaultvalue-after

Before

Previously the filter item would contract when the filter component had finished retrieving data but had not yet fully rendered the component:
filtertab-before

The default value selector didn't show that data was being awaited from the backend, but rather displayed "No results":
defaultvalue-before

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

Comment on lines 43 to 38
padding-bottom: 10px;
min-height: ${({ theme }) => theme.gridUnit * 10.5}px;
padding-bottom: ${({ theme }) => theme.gridUnit * 2.5}px;
Copy link
Member Author

Choose a reason for hiding this comment

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

The min height needs to be 32px + the bottom padding, which in gridUnits is 8 + 2.5 = 10.5.

Copy link
Member

Choose a reason for hiding this comment

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

I'm hoping/trying to avoid fractional gridUnits if at all possible. I know there are a few kicking around in the codebase, but (a) we should just learn to stick to the grid for the sake of design's sanity, and (b) ththings can get weird if gridUnit is ever moved to, say, 5px, and we find ourselves in fractional-pixel land.

Copy link
Member Author

@villebro villebro Mar 27, 2021

Choose a reason for hiding this comment

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

Ha - I looked at the designs, and turns out they were more like 12 than 10 - updating accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

Same with the line above btw. Maybe 10px is fine?

Comment on lines -115 to -121
if (loading) {
return (
<StyledLoadingBox>
<Loading />
</StyledLoadingBox>
);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This needed to be moved inside the FilterItem, otherwise the title disappears when loading.

@codecov
Copy link

codecov bot commented Mar 25, 2021

Codecov Report

Merging #13794 (9c90885) into master (18ff484) will increase coverage by 0.33%.
The diff coverage is 92.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13794      +/-   ##
==========================================
+ Coverage   77.22%   77.56%   +0.33%     
==========================================
  Files         935      935              
  Lines       47266    47276      +10     
  Branches     5893     5905      +12     
==========================================
+ Hits        36502    36668     +166     
+ Misses      10616    10464     -152     
+ Partials      148      144       -4     
Flag Coverage Δ
cypress 56.06% <100.00%> (-3.95%) ⬇️
javascript 63.75% <62.96%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/components/Loading/index.tsx 100.00% <ø> (ø)
...tersConfigModal/FiltersConfigForm/DefaultValue.tsx 93.10% <90.00%> (+2.62%) ⬆️
...veFilters/FilterBar/FilterControls/FilterValue.tsx 85.18% <100.00%> (-0.27%) ⬇️
...ters/FiltersConfigModal/FiltersConfigForm/state.ts 89.47% <100.00%> (+0.58%) ⬆️
...set-frontend/src/dashboard/util/getDropPosition.js 90.90% <0.00%> (-1.52%) ⬇️
...erset-frontend/src/SqlLab/components/ResultSet.tsx 68.64% <0.00%> (-0.30%) ⬇️
...rontend/src/SqlLab/components/AceEditorWrapper.tsx 61.25% <0.00%> (+1.25%) ⬆️
...rontend/src/visualizations/FilterBox/FilterBox.jsx 73.58% <0.00%> (+1.25%) ⬆️
...erset-frontend/src/SqlLab/components/SqlEditor.jsx 56.01% <0.00%> (+1.38%) ⬆️
...ntend/src/explore/components/ExploreChartPanel.jsx 82.60% <0.00%> (+1.44%) ⬆️
... and 18 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 18ff484...9c90885. Read the comment docs.

@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Mar 25, 2021
@junlincc
Copy link
Member

LGTM! I will need to test it again in master, if everything looks good - after +ing compatibility with sync query, let's turn native filter on by default for Superset users :D @villebro this is awesome!

export default function LoadingBox() {
return (
<StyledLoadingBox>
<Loading />
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth trying

Suggested change
<Loading />
<Loading position="inline" />

to see if it's a little smaller, and sits well. It might be left aligned, but if that looks strange, then StyledLoadingBox could also have text-align: center;

Copy link
Member

Choose a reason for hiding this comment

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

Actually, now that I look at this again, if you do the <Loading position="inline" /> bit, then you no longer need the position: relative; or height: ${({ theme }) => theme.gridUnit * 8}px; styles. This feels a bit cleaner to me.

Of course... it may be worth pointing out that if you don't mind the Loading icon being left-aligned, then you could skip that text-align: center; style.... which means you don't need the StyledLoadingBox div at all... which means you don't need the LoadingBox component at all.

And now, to completely belabor this...
If you DO want the loading centered, but think you might want that to be highly reusable, and don't want to bother with adding the LoadingBox component, then you can edit src/component/Loading/index.tsx and add the functionality there:

  1. Add an inline-centered class following the inline class:
&.inline {
    margin: 0px;
    width: 30px;
  }
  &.inline-centered {
    margin: 0 auto;
    width: 30px;
    display: block;
  }
  1. Update PositionOption to include inline-centered
  2. Simply use <Loading position="inline-centered" /> in FilterValue.tsx instead of <LoadingBox />

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

I added a bunch of comments on how to remove some of this new code, and instead extend the Loading component with a centered version, in case you want to make this all a bit smaller. If you do, please update the Loading Storybook entry too.

That said, what you have works quite well, and I've tested it locally to confirm. Approving.

@villebro
Copy link
Member Author

Thanks @rusackas! I'll address all the low hanging fruit from your comments today and get this merged to unblock pending follow-up PRs (we can further improve the aesthetics in future PRs)

@villebro villebro force-pushed the villebro/native-filter-style branch from b1cd528 to 359fe36 Compare March 29, 2021 06:23
@villebro villebro force-pushed the villebro/native-filter-style branch from 359fe36 to 9c90885 Compare March 29, 2021 06:42
@villebro villebro merged commit 9fa52b5 into apache:master Mar 29, 2021
@villebro villebro deleted the villebro/native-filter-style branch March 29, 2021 07:23
amitmiran137 added a commit that referenced this pull request Mar 31, 2021
* master: (56 commits)
  test: Adds tests and storybook to CertifiedIcon component (#13457)
  chore: Moves CheckboxIcons to Checkbox folder (#13459)
  chore: Removes Popover duplication (#13462)
  build(deps): bump elliptic from 6.5.3 to 6.5.4 in /docs (#13527)
  fix: allow spaces in DB names (#13800)
  chore: Update PR template for SIP-59 DB migrations process (#13855)
  Add CODEOWNERS (#13759)
  feat(alerts & reports): Easier to read execution logs (#13752)
  fix: Disallows negative options remaining (#13749)
  Fix broken link (#13861)
  fix(native-filters): add global async query support to native filters (#13837)
  Displays row limit warning with Alert component (#13854)
  fix(errors): Downgrade error on stop query to a warning (#13826)
  fix(alerts and reports): Unify timestamp format on execution log view (#13718)
  fix(sqllab): warning message when rows limited (#13841)
  chore: add success log whenever a connection is working (#13811)
  fix(native-filters): improve loading styles for filter component (#13794)
  chore: update change log with cherry-picks for release 1.1 (#13824)
  feat: added support to configure the default explorer viz (#13610)
  fix(#13734): Properly escape special characters in CSV output  (#13735)
  ...
allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
…che#13794)

* fix(native-filters): improve loading styles for filter component

* round up fractional grid unit

* remove LoadingBox
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.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 dashboard:native-filters Related to the native filters of the Dashboard preset-io size/L 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants