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

[docs] Improve sorting documentation page #3564

Merged
merged 25 commits into from
Jan 26, 2022

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Jan 7, 2022

Doc preview

Closes #1511

Package changes

  • Expose the built-in comparator to let the user use them when building custom comparator. They check for nullish value for instance, most of the time I don't think users should start a comparator from scratch.

Improve demos

  • Improve the custom comparator demo to display a fully-custom comparator and a custom comparator based on the build-in ones
  • Add demos for the initialization and the control of the model
  • Always use the same dataset (I used the same as filtering, maybe we could make this basic dataset more universal and use it on every demo where we care about the columns content and not the columns amount or sizing,
  • Only use controlled mode when it's the goal of the demo, otherwise use initialState

Improve paragraph order

Before:

image

After:

I have a few doubts on the titles of the sections
I tried to keep the order as close as the sorting one as possible to have a consistency.

image

@flaviendelangle flaviendelangle added the docs Improvements or additions to the documentation label Jan 7, 2022
@flaviendelangle flaviendelangle self-assigned this Jan 7, 2022
@mui-bot
Copy link

mui-bot commented Jan 18, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 180.1 504.7 341.6 332.74 108.92
Sort 100k rows ms 507.8 769.4 651.3 643.24 83.87
Select 100k rows ms 223.7 294.2 241.7 251.76 25.601
Deselect 100k rows ms 122.6 290.3 221.5 219.08 63.169

Generated by 🚫 dangerJS against 8610917

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 19, 2022
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 19, 2022
@flaviendelangle flaviendelangle marked this pull request as ready for review January 19, 2022 10:21
Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Seem realy nice. I only read the markdown. I re-request my review to read example later


A sorted column can be can pre-configured using the `sortModel` prop:
## Single and multi-sorting
Copy link
Member

Choose a reason for hiding this comment

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

This section content is only about multi-sorting

Suggested change
## Single and multi-sorting
## Single and multi-sorting [<span class="plan-pro"></span>](https://mui.com/store/items/material-ui-pro/)

Copy link
Member Author

Choose a reason for hiding this comment

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

https://deploy-preview-3437--material-ui-x.netlify.app/components/data-grid/filtering/#single-and-multi-filtering

We did not put the pro label on the filtering because the section also contains the mention that the DataGrid does not handle multi filtering / multi sorting.

Copy link
Member

Choose a reason for hiding this comment

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

That's a good point, @flaviendelangle. But I've just recently reviewed the license page, and because we mention there we'd add the label on pro (and premium) features, I agree we should consider adding the 'pro' label here.
Could we also consider making a patch for the filtering page regarding the changes we discuss here?

Having that said, I like the highlight box stating an important difference between the free and pro versions.
Perhaps we can leave this section as is and add a specific labeled section for the multi-sorting just after it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm in favor of consistency
But if the best output is with the pro icon, then there is no problem adding it to the filter page at the same time 👍

Perhaps we can leave this section as is and add a specific labeled section for the multi-sorting just after it.

I added it to see based on https://github.com/mui-org/material-ui-x/pull/3564/files#r791072821 to see what it would look like.
If we agree it's better that way, I'll do the same for filtering.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I think the preview is looking great.


{{"demo": "pages/components/data-grid/sorting/ControlledSort.js", "bg": "inline", "defaultCodeOpen": false}}

## Disable the sorting
Copy link
Member

Choose a reason for hiding this comment

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

I think this section could be introduced before multi sorting because: It does not need to know the existence of multi-sorting, and it is simpler to understand than sorting model

Copy link
Member Author

Choose a reason for hiding this comment

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

Would you have the same logic for filtering ?
I kept the same order between the two pages as the logic are similar.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know.

Having the same structure is clearly a good point (I was wondering why the flow seems familiar 😅)

I noticed it for this page (and not the filtering one) because here goes from a section with 3 subsections to a small section with one sentence + an example.

Let see if @joserodolfofreitas and @cherniavskii have an opinion

Copy link
Member

Choose a reason for hiding this comment

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

As I understand both single and multi-sorting works out of the box without any explicit configuration.
it can't be easier than that ;)

Maybe we should add a comment on the demo code that the configuration is optional, or remove the configuration altogether. Although I understand it's useful to have the demo showing by default the sorted data, so we have to weigh on that too.

Another point I see: it's good to highlight this hot pro feature (single vs multi) on the beginning of the page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure to follow you here

or remove the configuration altogether

What configuration are we talking about ?

Copy link
Member

@joserodolfofreitas joserodolfofreitas Jan 26, 2022

Choose a reason for hiding this comment

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

You're right, there's no configuration on the single sorting and multi sorting basic demos (great!). I may have mixed it with another one that sets a default sorting rule (which was the config I was referring to). My bad!

Copy link
Member Author

Choose a reason for hiding this comment

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

You can disable the multi sorting on the pro
But I think this option mainly exist to limit on the free, we don't even document it 👍

docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
@alexfauquette alexfauquette self-requested a review January 19, 2022 12:48
flaviendelangle and others added 7 commits January 19, 2022 16:51
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com>
flaviendelangle and others added 2 commits January 20, 2022 15:40
Co-authored-by: Matheus Wichman <matheushw@outlook.com>
Co-authored-by: Matheus Wichman <matheushw@outlook.com>
flaviendelangle and others added 3 commits January 20, 2022 15:40
Co-authored-by: Matheus Wichman <matheushw@outlook.com>
Co-authored-by: Matheus Wichman <matheushw@outlook.com>
…id.tsx

Co-authored-by: Matheus Wichman <matheushw@outlook.com>

const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin'];

export default function BasicExampleDataGrid() {
Copy link
Member

Choose a reason for hiding this comment

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

I've noticed that country sorting doesn't work in this demo

Screen.Recording.2022-01-20.at.17.05.04.mov

I can reproduce it in storybook as well.

It seemed like an easy fix at first - just a matter of adding valueGetter, so that column gets sorted by country label.
It didn't work though.
Adding valueGetter broke renderCell, since renderCell now receives a string (returned by valueGetter) instead of whole field object.
I did not expect that and at this point I'm not sure if that's intended.

I can extract it into a separate issue and investigate, so that this PR is not blocked by it.

Copy link
Member

Choose a reason for hiding this comment

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

docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved

A sorted column can be can pre-configured using the `sortModel` prop:
## Single and multi-sorting
Copy link
Member

Choose a reason for hiding this comment

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

That's a good point, @flaviendelangle. But I've just recently reviewed the license page, and because we mention there we'd add the label on pro (and premium) features, I agree we should consider adding the 'pro' label here.
Could we also consider making a patch for the filtering page regarding the changes we discuss here?

Having that said, I like the highlight box stating an important difference between the free and pro versions.
Perhaps we can leave this section as is and add a specific labeled section for the multi-sorting just after it.

docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
Copy link
Member

@joserodolfofreitas joserodolfofreitas left a comment

Choose a reason for hiding this comment

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

It's looking great!
I added just a small fix I missed on the "single vs multi" highlight box

docs/src/pages/components/data-grid/sorting/sorting.md Outdated Show resolved Hide resolved
Co-authored-by: José Rodolfo Freitas <joserodolfo.freitas@gmail.com>
@flaviendelangle flaviendelangle merged commit 6be6e0d into mui:master Jan 26, 2022
@flaviendelangle flaviendelangle deleted the sorting-doc branch January 26, 2022 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] How does custom sorting comparators work?
6 participants