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

Optimize GridToolbarQuickFilter (the search input above the DataGrid) #3213

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-poems-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/admin": minor
---

Make the width of `GridToolbarQuickFilter` responsive when used inside `DataGridToolbar`
5 changes: 5 additions & 0 deletions .changeset/witty-garlics-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/admin-theme": minor
---

Prevent the input value of `GridToolbarQuickFilter` from being truncated too early
11 changes: 11 additions & 0 deletions packages/admin/admin-theme/src/componentsTheme/MuiDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ export const getMuiDataGrid: GetMuiComponentTheme<"MuiDataGrid"> = (component, {
styleOverrides: mergeOverrideStyles<"MuiDataGrid">(component?.styleOverrides, {
root: {
backgroundColor: "white",

"& [class*='MuiDataGrid-toolbarQuickFilter']": {
[`& > .${inputBaseClasses.root} .${inputBaseClasses.input}`]: {
paddingRight: 0, // Removes unnecessary spacing to the clear button that already has enough spacing
textOverflow: "ellipsis",
},

[`& > .${inputBaseClasses.root} .${inputBaseClasses.input}[value=''] + .${iconButtonClasses.root}`]: {
display: "none", // Prevents the disabled clear-button from overlaying the input value
},
},
},
columnsPanelRow: {
marginBottom: spacing(2),
Expand Down
12 changes: 12 additions & 0 deletions packages/admin/admin/src/common/toolbar/DataGridToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const Root = createComponentSlot(Toolbar)<DataGridToolbarClassKey, OwnerState>({
},
})(
({ ownerState, theme }) => css`
[class*="MuiDataGrid-toolbarQuickFilter"] {
width: 120px;

${theme.breakpoints.up("sm")} {
width: 150px;
}

${theme.breakpoints.up("md")} {
width: "auto";
}
}

${ownerState.density === "comfortable" &&
css`
min-height: 80px;
Expand Down
Loading