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

[DataGrid] New Toolbar component #14611

Open
wants to merge 191 commits into
base: master
Choose a base branch
from

Conversation

KenanYusuf
Copy link
Member

@KenanYusuf KenanYusuf commented Sep 13, 2024

Adds a redesigned Toolbar component through a new composition API, documented here:

There are several related components that users can use to build a custom toolbar:

Note

This PR only adds the building blocks to create custom toolbars, and documentation for those components. I'm hoping we can release these in v7 for users to try out. There will be a follow up to update the default grid toolbar for v8 to use the new components. #15823

Closes #11584


Follow-up tasks:

@KenanYusuf KenanYusuf added component: data grid This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer proof of concept Studying and/or experimenting with a to be validated approach labels Sep 13, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 18, 2024
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 Nov 1, 2024
Copy link
Contributor

@mapache-salvaje mapache-salvaje left a comment

Choose a reason for hiding this comment

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

this is mostly repetitive and minor style stuff—the bulk of the content is in great shape.

@@ -50,6 +50,13 @@ As mentioned above, the column menu is a component slot that can be recomposed e

### Toolbar

:::warning

The examples below use the `<GridToolbar />`, `<GridToolbarContainer />`, and various toolbar button components.
Copy link
Contributor

Choose a reason for hiding this comment

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

solid example of the component case in action - this text could be harder to understand if it was plain text 👍

"disabled": { "description": "If <code>true</code>, the component is disabled." },
"disableElevation": { "description": "If <code>true</code>, no elevation is used." },
"disableFocusRipple": {
"description": "If <code>true</code>, the keyboard focus ripple is disabled."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "If <code>true</code>, the keyboard focus ripple is disabled."
"description": "If <code>true</code>, the keyboard focus ripple is disabled."

"description": "The component used to render a link when the <code>href</code> prop is provided."
},
"onFocusVisible": {
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too."
"description": "Callback fired when the component is focused with a keyboard. Also triggers an <code>onFocus</code> callback."

},
"startIcon": { "description": "Element placed before the children." },
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
"description": "The system prop for defining system overrides and additional CSS styles."

"description": "The component used to render a link when the <code>href</code> prop is provided."
},
"onFocusVisible": {
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too."
"description": "Callback fired when the component is focused with a keyboard. Also triggers an <code>onFocus</code> callback."

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestions on these . The remaining suggestions are prop descriptions that are being generated from the Material UI components they extend. I will add a follow-up item to update these at the source.

Comment on lines +16 to +18
<ColumnsPanelTrigger render={<ToolbarButton />}>
<ViewColumnIcon fontSize="small" />
</ColumnsPanelTrigger>
Copy link
Member

Choose a reason for hiding this comment

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

Are these 2 snippets equal?

<ColumnsPanelTrigger render={<ToolbarButton />}>
  <ViewColumnIcon fontSize="small" />
</ColumnsPanelTrigger>
<ColumnsPanelTrigger render={<ToolbarButton><ViewColumnIcon fontSize="small" /></ToolbarButton>} />

Copy link
Member Author

Choose a reason for hiding this comment

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

They are, it comes down to preference. Do you think it's worth documenting this on the usage page?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think it's worth clarifying that children are automatically passed to the render element. Otherwise, it might be a bit "magical" for an average user 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Mentioned it here - let me know how that sounds.

Copy link
Member

Choose a reason for hiding this comment

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

If I understood correctly, it makes more sense to use render prop if there's a need to access props or state.

<ColumnsPanelTrigger render={(props) => <ToolbarButton {...props} />}>
  <ViewColumnIcon fontSize="small" />
</ColumnsPanelTrigger>

Is it possible to skip the render prop for simple use cases?

<ColumnsPanelTrigger>
  <ToolbarButton>
    <ViewColumnIcon fontSize="small" />
  </ToolbarButton>
</ColumnsPanelTrigger>

Copy link
Member Author

@KenanYusuf KenanYusuf Feb 28, 2025

Choose a reason for hiding this comment

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

If I understood correctly, it makes more sense to use render prop if there's a need to access props or state.

That's a reason to pass a function to the render prop. The other case is to merge functionality and change the element rendered by a component.

Is it possible to skip the render prop for simple use cases?

In this example, no. The <ColumnsPanelTrigger /> and <ToolbarButton /> both render a <button />, so you would end up with this:

<button>
  <button>
     <svg />
  </button>
</button>

By using the render prop like: <ColumnsPanelTrigger render={<ToolbarButton />}><ViewColumnIcon /></ColumnsPanelTrigger>, the styled button element rendered by <ToolbarButton /> is the only element that gets rendered but with the merged attributes from both elements:

<button>
  <svg />
</button>

I will update the usage doc to try to explain this better.

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've made some updates to the Usage doc. Let me know if there's anything that could be clarified further.

@arminmeh
Copy link
Contributor

Besides the latest open points LGTM
Really like the demos in the docs 💯

},
);

ExportExcel.propTypes = {
Copy link
Member

Choose a reason for hiding this comment

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

Sidenote: Should we stop generating propTypes for new components since they are already deprecated and on a path to being removed in subsequent React versions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that at this point, the CI would complain. For me it is fine if it is done together whit other propTypes being removed

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we stop generating propTypes for new components

I think they are required for API docs generation too currently.

Copy link
Member

Choose a reason for hiding this comment

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

@KenanYusuf Correct

Comment on lines +16 to +18
<ColumnsPanelTrigger render={<ToolbarButton />}>
<ViewColumnIcon fontSize="small" />
</ColumnsPanelTrigger>
Copy link
Member

Choose a reason for hiding this comment

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

If I understood correctly, it makes more sense to use render prop if there's a need to access props or state.

<ColumnsPanelTrigger render={(props) => <ToolbarButton {...props} />}>
  <ViewColumnIcon fontSize="small" />
</ColumnsPanelTrigger>

Is it possible to skip the render prop for simple use cases?

<ColumnsPanelTrigger>
  <ToolbarButton>
    <ViewColumnIcon fontSize="small" />
  </ToolbarButton>
</ColumnsPanelTrigger>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: dom Component's DOM customizability, e.g. slot design This is about UI or UX design, please involve a designer new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Improved Toolbar
8 participants