I'm learning MUI 5 component design. Can anyone tell me where is the logic that control clicking outside of a component, the component itself will close?
I couldn't find it from the souce code.
It has applied on select component and dialog component.
There is a component called ClickAwayListener available to handleOutSideClick, you need to wrap your select or dialog component into it.
You just need to pass a function to a prop called onClickAway to the ClickAwayListener component to handle the case when clicking outside.
here is a demo example of it from MUI's official document.