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] Pressing Escape should close GridColumnHeaderMenu without errors #2463

Merged

Conversation

DanailH
Copy link
Member

@DanailH DanailH commented Aug 27, 2021

Found a regression that is a quick win.

Currently pressing the Escape key when the GridColumnHeaderMenu is opened results in an error in the console and the menu doesn't close. This PR fixes the broken behavior.

@DanailH DanailH added the bug 🐛 Something doesn't work label Aug 27, 2021
@DanailH DanailH self-assigned this Aug 27, 2021
@DanailH DanailH added accessibility a11y component: data grid This is the name of the generic UI component, not the React module! regression A bug, but worse and removed bug 🐛 Something doesn't work labels Aug 27, 2021
@flaviendelangle
Copy link
Member

In GridColumnHeaderMenu, could we type the params of hideMenu ?
GridMenu tells us that the event can be null but the hideMenu is doing like if it was never null.

@oliviertassinari
Copy link
Member

It would be interesting to dive into why we need the event.

@DanailH
Copy link
Member Author

DanailH commented Aug 27, 2021

It would be interesting to dive into why we need the event.

event.stopPropagation();

That is why it is breaking. The comment explanation is 'Prevent triggering the sorting'. This is the commit that introduced the change DanailH@382e84b#diff-ac3c8d72bf2d6735fd89cf6d93298a21dce356400957fac9b93263b7c61eb381R30

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 27, 2021

Ok, Interesting, the event.stopPropagation purpose seems to be backward. From what I understand.

  • Calling event.stopPropagation(); when the Escape key is pressed could help avoid double handling of the event. We use it in the Modal. Maybe we should normalize it. The alternative is to not call it, but set event.defaultMuiPrevented = true.
  • Calling event.stopPropagation(); so it doesn't sort doesn't work, it's a dead logic, I can still sort. Worse, it might prevent developers to listen to the event.

@m4theushw
Copy link
Member

Calling event.stopPropagation(); so it doesn't sort doesn't work, it's a dead logic, I can still sort. Worse, it might prevent developers to listen to the event.

@oliviertassinari It's working. Its purpose is for when a menu item is clicked it doesn't sort the respective column too. What we could do to not prevent every event is to only call event.preventDefault(); on non-keyboard events.

@oliviertassinari
Copy link
Member

@m4theushw Ohh, right, I see. My bad.

@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Aug 27, 2021
@oliviertassinari oliviertassinari removed their request for review August 31, 2021 15:20
@DanailH DanailH merged commit 2cd18f9 into mui:next Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! regression A bug, but worse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants