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

feat: Adds virtualization option to antd based Table component #22135

Conversation

eric-briscoe
Copy link
Contributor

SUMMARY

This PR adds a virtualization prop to the recently added ant based Table component. Virtualization allows the tables to be used in cases where there are hundreds or thousands of columns, or large dataset with many thousands of rows with no pagination enabled.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

  1. Checkout PR and open console at superset/superset-frontend
  2. run npm ci
  3. run npm run storybook and view docs and test virtualized table at: http://localhost:6006/?path=/story/design-system-components-table-overview--page under the "Virtualization for Performance" section, or interact directly with virtualized table instance at: http://localhost:6006/?path=/story/design-system-components-table-examples--virtualized-performance
  4. Ensure the other table example stories work correctly
  5. run npm run dev-server and go to http://localhost:9000/dataset/add/?testing to ensure the table instance used in the create dataset workflow still behaves as expected following instructions on this prior PR: feat: Integrate ant d table component into DatasetPanel #21948

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

@eric-briscoe eric-briscoe changed the title Adds virtualization option to antd based Table component feat: Adds virtualization option to antd based Table component Nov 16, 2022
Copy link
Member

@lyndsiWilliams lyndsiWilliams left a comment

Choose a reason for hiding this comment

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

Found a couple of theming nits, otherwise it looks great!

superset-frontend/src/components/Table/Table.overview.mdx Outdated Show resolved Hide resolved
superset-frontend/src/components/Table/VirtualTable.tsx Outdated Show resolved Hide resolved
superset-frontend/src/components/Table/index.tsx Outdated Show resolved Hide resolved
@EugeneTorap
Copy link
Contributor

EugeneTorap commented Nov 16, 2022

Hello @eric-briscoe. Thanks for this PR!
I have some questions about VirtualTable:

  • There's react-virtual (5.3 kB) which 3 times less than rc-resize-observer (15.6 kB) and provides hook for this func component. Should we use react-virtual for this VirtualTable?
  • Why do we use antd based Table instead of react-table. react-table already supports virtualization - virtualized-infinite-scrolling and virtualized-rows
  • Can we also use the VirtualTable in FilterableTable for result data in SQL Lab

eric-briscoe and others added 3 commits November 17, 2022 14:53
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
Co-authored-by: Lyndsi Kay Williams <55605634+lyndsiWilliams@users.noreply.github.com>
…nt resize, reverts package and package-lock changes for the dependency, adjusts theme usage in multiple places
@eric-briscoe
Copy link
Contributor Author

Hello @eric-briscoe. Thanks for this PR! I have some questions about VirtualTable:

  • There's react-virtual (5.3 kB) which 3 times less than rc-resize-observer (15.6 kB) and provides hook for this func component. Should we use react-virtual for this VirtualTable?
  • Why do we use antd based Table instead of react-table. react-table already supports virtualization - virtualized-infinite-scrolling and virtualized-rows
  • Can we also use the VirtualTable in FilterableTable for result data in SQL Lab

@EugeneTorap Great questions!

@michael-s-molina noted in a diff comment on this PR we already have 'react-resize-detector' as a dependency used in components such as MetadataBar so I refactored to use that library in place of rc-resize-observer and this PR introduces no new dependencies now

Bigger picture, the introduction of src/components/Table based on antd is continuing of work started with #20159 (SIP-82) about more consistent theming, use of Ant Design components and establishing a formal design system using antd as a base for new components.

VitrualTable is never intended to be used directly. It is a sub component to enable the src/components/Table to operate in a virtualized mode if needed and implementation is based from this antd example, then modified for our needs: https://ant.design/components/table/#components-table-demo-virtual-list

If you check out PR and run storybook, you will see the documentation for using the new Table component, and in this PR docs on using the virtualize prop have been added.

As far as using a different library such as react-table I was asked to use antd for consistency in a single Table implementation so that features like column definitions, sort functions, cell renderers, data formats, etc can be consistent, and the UI controls are consistent wether we are using the Table with or without virtualization.

Regarding use in SqlLab, the goal is to replace eventually replace all tables across superset-frontend with the new src/components/Table (but never VirtualTable directly). Table uses VirtualTable as a sub component when the Table prop virtualize is set to true. This allows of are lot of the common logic between virtual and non-virtual rendering to be handled at the Table component level and not duplicated in VirtualTable.

I was asked to introduce the Table capability incrementally so that it can be used for the new dataset creation and editing workflows, fix issues in the drill to detail modal, and the target other high use areas of the app to start swapping out. Some Table features will be need to be exposed / added as we do this and features refined as it gets used more. I was also asked to make Table an abstraction to antd so that it can leverage antd components but streamline usage for Superset use cases and not require developer to understand / use antd directly. That is bigger picture goal for design system which will likely be a follow on SIP to SIP-82, but still doing some research / prototyping to get this ready for community discussion.

I would really appreciate more eyes on the storybook examples and documentation so we can improve it to make usage as clear and efficient as possible for all Superset contributors. If you have any time to take a look and have feedback please send my way!

@EugeneTorap
Copy link
Contributor

@eric-briscoe Thank you for your answer! I like what you do!

@michael-s-molina
Copy link
Member

Can we eliminate the scroll space of the table when there's no scroll?

Screen Shot 2022-11-18 at 4 21 43 PM

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
@michael-s-molina
Copy link
Member

When using virtualize the render function is not being called which prevents me from formatting the content.

… when no scroll is needed, fixes virtual width calculation with box-sizing,
…-component' of ssh://github.com/preset-io/superset into ericbriscoe/sc-62459/enable-virtualization-in-new-table-component
@eric-briscoe
Copy link
Contributor Author

When using virtualize the render function is not being called which prevents me from formatting the content.

@michael-s-molina support for the render function on column definitions when in virtualized mode has bee added in latest commit

@michael-s-molina
Copy link
Member

@eric-briscoe Can you add the behavior to scroll to the top when paginating?

@michael-s-molina
Copy link
Member

@eric-briscoe We have the concept of column formatting as you can see in the screenshot below:

Screen Shot 2022-11-23 at 9 45 37 AM

I'm wondering about the best approach to implement this. It looks pretty similar to the filters concept provided by Ant Design's table. If we follow the same pattern, we can have formattings, defaultFormatting, onFormatting properties on ColumnsType to create the popup selector. We would also need to provide a TimeCell renderer that can be used when rendering dates/timestamps/numbers. WDYT?

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and for addressing the comments @eric-briscoe. I'll tackle the formatting problem in another PR as we discussed.

@michael-s-molina michael-s-molina merged commit eba7b3d into apache:master Nov 25, 2022
@EugeneTorap
Copy link
Contributor

@eric-briscoe @michael-s-molina
I found a bug when I use virtualize and usePagination={false} at the same time, I still see pagination!

@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/XL 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants