-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[DataGrid] Add missing slotProps to panel interface
#22651
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
base: master
Are you sure you want to change the base?
Changes from all commits
7942972
f59452c
50a1e27
093c6b6
14eb4a2
2ee4d21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import * as React from 'react'; | ||
| import { DataGrid } from '@mui/x-data-grid'; | ||
| import { useDemoData } from '@mui/x-data-grid-generator'; | ||
|
|
||
| const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin']; | ||
|
|
||
| export default function FilterPanelPlacementColumnHeadersNoSnap() { | ||
| const { data, loading } = useDemoData({ | ||
| dataSet: 'Employee', | ||
| visibleFields: VISIBLE_FIELDS, | ||
| rowLength: 100, | ||
| }); | ||
|
|
||
| const columnHeadersRef = React.useRef(null); | ||
|
|
||
| return ( | ||
| <div style={{ height: 400, width: '100%' }}> | ||
| <DataGrid | ||
| {...data} | ||
| loading={loading} | ||
| showToolbar | ||
| slotProps={{ | ||
| columnHeaders: { | ||
| ref: columnHeadersRef, | ||
| }, | ||
| panel: { | ||
| placement: 'bottom-start', | ||
| target: columnHeadersRef.current, | ||
| }, | ||
| }} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import * as React from 'react'; | ||
| import { DataGrid } from '@mui/x-data-grid'; | ||
| import { useDemoData } from '@mui/x-data-grid-generator'; | ||
|
|
||
| const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin']; | ||
|
|
||
| export default function FilterPanelPlacementColumnHeadersNoSnap() { | ||
| const { data, loading } = useDemoData({ | ||
| dataSet: 'Employee', | ||
| visibleFields: VISIBLE_FIELDS, | ||
| rowLength: 100, | ||
| }); | ||
|
|
||
| const columnHeadersRef = React.useRef<HTMLDivElement>(null); | ||
|
|
||
| return ( | ||
| <div style={{ height: 400, width: '100%' }}> | ||
| <DataGrid | ||
| {...data} | ||
| loading={loading} | ||
| showToolbar | ||
| slotProps={{ | ||
| columnHeaders: { | ||
| ref: columnHeadersRef, | ||
| }, | ||
| panel: { | ||
| placement: 'bottom-start', | ||
| target: columnHeadersRef.current, | ||
| }, | ||
| }} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <DataGrid | ||
| {...data} | ||
| loading={loading} | ||
| showToolbar | ||
| slotProps={{ | ||
| columnHeaders: { | ||
| ref: columnHeadersRef, | ||
| }, | ||
| panel: { | ||
| placement: 'bottom-start', | ||
| target: columnHeadersRef.current, | ||
| }, | ||
| }} | ||
| /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,10 +23,7 @@ export interface GridPanelClasses { | |
| paper: string; | ||
| } | ||
|
|
||
| export interface GridPanelProps extends Pick< | ||
| GridSlotProps['basePopper'], | ||
| 'id' | 'className' | 'target' | 'flip' | ||
| > { | ||
| export interface GridPanelProps extends Omit<GridSlotProps['basePopper'], 'ref'> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (1) This widening exposes the The I think it is safer to keep the existing Could be something like this: Pick<
GridSlotProps['basePopper'],
'id' | 'className' | 'target' | 'flip' | 'placement' | 'focusTrap'
>For the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (2) Minor: with this
- open: boolean;
onClose?: () => void; |
||
| ref?: React.Ref<HTMLDivElement>; | ||
| children?: React.ReactNode; | ||
| /** | ||
|
|
@@ -134,11 +131,48 @@ GridPanel.propTypes = { | |
| */ | ||
| classes: PropTypes.object, | ||
| className: PropTypes.string, | ||
| clickAwayMouseEvent: PropTypes.oneOf([ | ||
| 'onClick', | ||
| 'onMouseDown', | ||
| 'onMouseUp', | ||
| 'onPointerDown', | ||
| 'onPointerUp', | ||
| false, | ||
| ]), | ||
| clickAwayTouchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false]), | ||
| flip: PropTypes.bool, | ||
| focusTrap: PropTypes.bool, | ||
| id: PropTypes.string, | ||
| onClickAway: PropTypes.func, | ||
| onClose: PropTypes.func, | ||
| onDidHide: PropTypes.func, | ||
| onDidShow: PropTypes.func, | ||
| onExited: PropTypes.func, | ||
| open: PropTypes.bool.isRequired, | ||
| /** | ||
| * @default 'bottom' | ||
| */ | ||
| placement: PropTypes.oneOf([ | ||
| 'auto-end', | ||
| 'auto-start', | ||
| 'auto', | ||
| 'bottom-end', | ||
| 'bottom-start', | ||
| 'bottom', | ||
| 'left-end', | ||
| 'left-start', | ||
| 'left', | ||
| 'right-end', | ||
| 'right-start', | ||
| 'right', | ||
| 'top-end', | ||
| 'top-start', | ||
| 'top', | ||
| ]), | ||
| role: PropTypes.string, | ||
| style: PropTypes.object, | ||
| target: PropTypes /* @typescript-to-proptypes-ignore */.any, | ||
| transition: PropTypes.bool, | ||
| } as any; | ||
|
|
||
| export { GridPanel }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this demo customizes the panel placement that is not visible when the screenshot is taken, I've excluded it from being screenshoted.