-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add ability to reorder fields in DatagridConfigurable and SimpleFormConfigurable #8416
Conversation
@@ -177,7 +182,7 @@ const StyledPaper = styled(Paper, { | |||
overridesResolver: (props, styles) => styles.root, | |||
})(({ theme }) => ({ | |||
position: 'fixed', | |||
zIndex: theme.zIndex.modal, | |||
zIndex: theme.zIndex.modal + 1, |
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.
This one is a fix for a regression appearing since #8395: the configure button appears on top of the inspector
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.
I believe you forgot to update the screencast.
And maybe a few tests wouldn't hurt 😃
Screencasts added. As for the tests, they are left as an exercise for the reader ;) |
const handleMove = (index1, index2) => { | ||
const index1Pos = availableFields.findIndex( | ||
// eslint-disable-next-line eqeqeq | ||
field => field.index == index1 | ||
); | ||
const index2Pos = availableFields.findIndex( | ||
// eslint-disable-next-line eqeqeq | ||
field => field.index == index2 | ||
); | ||
if (index1Pos === -1 || index2Pos === -1) { | ||
return; | ||
} | ||
let newAvailableFields; | ||
if (index1Pos > index2Pos) { | ||
newAvailableFields = [ | ||
...availableFields.slice(0, index2Pos), | ||
availableFields[index1Pos], | ||
...availableFields.slice(index2Pos, index1Pos), | ||
...availableFields.slice(index1Pos + 1), | ||
]; | ||
} else { | ||
newAvailableFields = [ | ||
...availableFields.slice(0, index1Pos), | ||
...availableFields.slice(index1Pos + 1, index2Pos + 1), | ||
availableFields[index1Pos], | ||
...availableFields.slice(index2Pos + 1), | ||
]; | ||
} | ||
setAvailableFields(newAvailableFields); | ||
setFields(fields => | ||
newAvailableFields | ||
.filter(field => !omit?.includes(field.source)) | ||
.filter(field => fields.includes(field.index)) | ||
.map(field => field.index) | ||
); | ||
}; |
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.
Fun fact: this method was almost entirely written by gitHub Copilot!
Enregistrement.de.l.ecran.2022-11-21.a.18.28.25.mov
Enregistrement.de.l.ecran.2022-11-21.a.18.31.40.mov