Comments (6)
thanks for the suggestion @vovarudomanenko ... I think we could improve on this a bit with a very simple conditional logic on the slots side (as we do with many others as well).
What I mean is that we could use a default Popper (e.g. basePopper
) and, if present, use a custom one. Something like this:
diff --git a/packages/x-data-grid/src/components/menu/GridMenu.tsx b/packages/x-data-grid/src/components/menu/GridMenu.tsx
index cc00c12da..e3a33f2ee 100644
--- a/packages/x-data-grid/src/components/menu/GridMenu.tsx
+++ b/packages/x-data-grid/src/components/menu/GridMenu.tsx
@@ -108,9 +108,12 @@ function GridMenu(props: GridMenuProps) {
onClose(event);
};
+ const popperComponent = rootProps.slots?.menuPopper || rootProps.slots.basePopper;
+ const popperComponentSlots = rootProps.slotProps?.menuPopper || rootProps.slotProps.basePopper;
+
return (
<GridMenuRoot
- as={rootProps.slots.basePopper}
+ as={popperComponent}
className={clsx(className, classes.root)}
ownerState={rootProps}
open={open}
@@ -118,7 +121,7 @@ function GridMenu(props: GridMenuProps) {
transition
placement={position}
{...other}
- {...rootProps.slotProps?.basePopper}
+ {...popperComponentSlots}
>
{({ TransitionProps, placement }) => (
<ClickAwayListener onClickAway={handleClickAway} mouseEvent="onMouseDown">
@mui/xgrid WDYT?
from mui-x.
similar issue #8549
from mui-x.
@michelengelen I like your idea that we should keep the basePopper
slot and be able to replace it with menuPopper
slot. This way we won't break backward compatibility.
from mui-x.
The popper slot will require a rework to enable the material-less datagrid. I would avoid touching those slots until we have figured out how to make it work properly as that slot in particular is already a bit problematic. In particular, some of the functionality of the popper would need to be abstracted a bit behind a cleaner interface (e.g. handling the ClickAwayListener) like we implement the current Joy UI bindings.
If you have a workaround, I don't think we can provide anything better at the moment. We plan to rework the slots this quarter though.
from mui-x.
@romgrk Maybe I understood something wrong, but you described a different problem.
Even if you abstract the popper functionality behind a cleaner interface, the problem I encountered will not go away on its own. The basePropper
slot will still be used by two different panels (the column menu panel and the preference panel). This makes styling more difficult than it needs to be. If you plan to fix this when you redo the slots, that's okay, I just want to make sure you understand the problem.
from mui-x.
I understand the problem but I don't want to add slots now because we need to clarify our slot API first.
from mui-x.
Related Issues (20)
- [Datagrid-v7] theme.components.MuiDataGrid.styleOverrides.main no longer affects styles on 'MuiDataGrid-main' class/element HOT 1
- [charts] Highlighting not working in Scatter series with `number` ID HOT 2
- [data grid] Cannot transpile since latest update v7.0.0 HOT 9
- [data grid] Custom Header Keyboard Navigation HOT 4
- [data grid] singleSelect cell stays in edit mode after selection HOT 1
- [data grid] QuickFilter is not filtering from master details HOT 9
- [data grid] Allow a row to be wrapped in a Link HOT 2
- [tree view] Can't focus input inside TreeItem label HOT 3
- [data grid] how to select all visible rows on a page HOT 4
- [data grid] Selection and filtering do not work together HOT 1
- [docs] Demo ColDefChangesGridNoSnap crashes HOT 1
- [pickers][DatePicker] Toggle date selection when same date is clicked HOT 2
- [charts] Improve `sx` documentation
- [data grid] Export to Excel and CSV only displayed Data (filtered and sorted) HOT 1
- [DateTimeRangePicker] Different selection flow option HOT 2
- [data grid] Clipboard copy places unnecessary quotations when copied text contains a quotation HOT 4
- DesktopDatePickerProps<Date> error Type 'Date' does not satisfy the constraint 'never' in version 7.1.0 HOT 10
- [data grid] Export to Excel causes rows to be misaligned from their headers (with checkboxes present) HOT 3
- [data grid] rendering complex components in a cell push pieces to following rows HOT 3
- [data grid] Support the custom header filter height that is independent from the column header height HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mui-x.