Search code examples
material-uireact-dropzone

How can I prevent a SpeedDialAction that opens dialog from refocusing the SpeedDial when the dialog is closed?


I have a SpeedDialAction (@material-ui/[email protected]) that opens a file dialog. If you choose one or more files it opens a material-ui modal dialog. It's using react-dropzone, but I don't know if that's relevant here. At the beginning of the action click handler I set the open state on the SpeedDial to false, and it closes. When you:

  • cancel the file dialog
  • cancel the material-ui dialog
  • submit from the material-ui dialog

...afterwards the SpeedDial component's onOpen callback is called, and passed 'focus' as the reason. I'm not sure why this is happening or really which component is driving this behavior. Is there an easy way to suppress this?


Solution

  • The answer is in the docs: the disableRestoreFocus prop on Modal, which is inherited by Dialog.