Skip to content

Commit

Permalink
Optimize GridToolbarQuickFilter (the search input above the `DataGr…
Browse files Browse the repository at this point in the history
…id`) (#3213)

Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
  • Loading branch information
jamesricky and johnnyomair authored Jan 21, 2025
1 parent 4240d9b commit af51bb4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
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": patch
---

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

0 comments on commit af51bb4

Please sign in to comment.