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] Fix column menu position when closing #3289

Merged
merged 5 commits into from
Dec 6, 2021

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Nov 27, 2021

@m4theushw m4theushw added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Nov 27, 2021
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 29, 2021
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 29, 2021
@@ -150,12 +151,22 @@ function GridColumnHeaderItem(props: GridColumnHeaderItemProps) {
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
}

React.useEffect(() => {
if (!showColumnMenuIcon) {
setShowColumnMenuIcon(columnMenuOpen);
Copy link
Member

Choose a reason for hiding this comment

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

To only trigger this effect when the columnMenuOpen prop changes, should we remove this !showColumnMenuIcon
Updating from true to true is not a problem no ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose of this effect is: showColumnMenuIcon should always reflect the value of columnMenuOpen UNLESS showColumnMenuIcon=true.

It could be rewrote as setShowColumnMenuIcon(value => !value ? columnMenuOpen : value);. By the time this effect run, columnMenuOpen will already be false.

Updating from true to true is not a problem no ?

No, React won't rerender the component if the value didn't change.

packages/grid/_modules_/grid/components/menu/GridMenu.tsx Outdated Show resolved Hide resolved
@m4theushw m4theushw merged commit 328b51a into mui:master Dec 6, 2021
@m4theushw m4theushw deleted the fix-column-menu-position branch December 6, 2021 15:44
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
Development

Successfully merging this pull request may close these issues.

None yet

2 participants