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

[DataGrid] Ignore drag events when disableColumnReorder is true #1952

Merged
merged 5 commits into from Jun 24, 2021

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Jun 21, 2021

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Jun 21, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider writing an e2e test case for the reoder with: https://stackoverflow.com/a/64746679/2801714. It's not directly related to the two different bugs we fix, but 🤷‍♂️

packages/grid/x-grid/src/tests/reorder.XGrid.test.tsx Outdated Show resolved Hide resolved
@DanailH
Copy link
Member

DanailH commented Jun 22, 2021

Looks nice but you would also need to make ``

We could consider writing an e2e test case for the reoder with: https://stackoverflow.com/a/64746679/2801714. It's not directly related to the two different bugs we fix, but 🤷‍♂️

I'm also in favour of adding e2e test, it can be a simple one.

m4theushw and others added 3 commits June 22, 2021 23:51
@m4theushw
Copy link
Member Author

We could consider writing an e2e test case for the reoder with: https://stackoverflow.com/a/64746679/2801714. It's not directly related to the two different bugs we fix, but 🤷‍♂️

Done.

@@ -42,6 +43,7 @@ export const useGridColumnReorder = (apiRef: GridApiRef): void => {

const [, setGridState, forceUpdate] = useGridState(apiRef);
const dragCol = useGridSelector(apiRef, gridColumnReorderDragColSelector);
const options = useGridSelector(apiRef, optionsSelector);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can destructure 'disableColumnReorder'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in the future, if we could refactor the other usages of useGridSelector(apiRef, optionsSelector) to not destructure, it could be great. It would make it easier to find how the top level props are used in the codebase, allowing to grep option.x instead of x. These options tend to be all over the placef

@@ -42,6 +43,7 @@ export const useGridColumnReorder = (apiRef: GridApiRef): void => {

const [, setGridState, forceUpdate] = useGridState(apiRef);
const dragCol = useGridSelector(apiRef, gridColumnReorderDragColSelector);
const options = useGridSelector(apiRef, optionsSelector);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in the future, if we could refactor the other usages of useGridSelector(apiRef, optionsSelector) to not destructure, it could be great. It would make it easier to find how the top level props are used in the codebase, allowing to grep option.x instead of x. These options tend to be all over the placef

Comment on lines +170 to +174
await page.mouse.move(
brandBoundingBox.x + brandBoundingBox.width / 2,
brandBoundingBox.y + brandBoundingBox.height / 2,
{ steps: 5 },
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the logic, we could almost consider a drag & drop abstraction. Two repetitions might be a bit short to justify it. I'm only saying that it starts to show potential.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not just abstract the drag & drop but also other page.evaluate in this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have a chat with Sebastian about how to abstract the common patterns. We might be close to have enough tests here and in the core to make good decisions.

test/e2e/fixtures/DataGrid/ColumnReorder.tsx Outdated Show resolved Hide resolved
@m4theushw m4theushw merged commit 26fedc8 into mui:master Jun 24, 2021
@m4theushw m4theushw deleted the fix-dragging branch June 24, 2021 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
4 participants