[英]Can I stop Material-UI SpeedDial from closing when a SpeedDialAction button is clicked
I am wanting to disable the default behaviour of Material-UI's SpeedDial component ( https://material-ui.com/api/speed-dial/ ).我想禁用 Material-UI 的 SpeedDial 组件( https://material-ui.com/api/speed-dial/ )的默认行为。
Currently when you click a SpeedDialAction, the parent SpeedDial component will close.当前,当您单击 SpeedDialAction 时,父 SpeedDial 组件将关闭。
I would like to change the behaviour so that when a SpeedDialAction is clicked the parent SpeedDial component will stay open.我想更改行为,以便单击 SpeedDialAction 时,父 SpeedDial 组件将保持打开状态。
Is there a simple way for me to disable the 'closing' behaviour?有没有一种简单的方法可以禁用“关闭”行为?
Thanks!谢谢!
The SpeedDial
component's open state is controlled via the prop open
. SpeedDial
组件的打开状态是通过 prop open
控制的。 The default example for the SpeedDial
has the following onClick
function on the SpeedDialAction
component: SpeedDial
的默认示例在SpeedDialAction
组件上具有以下onClick
函数:
const handleClose = () => {
setOpen(false);
}
setOpen
sets the open
state to false
when an item is clicked, and this state is passed to the SpeedDial
component causing it to close.当一个项目被点击时, setOpen
将open
状态设置为false
,并且这个状态被传递给SpeedDial
组件,导致它关闭。
So, just don't set this state in the onClick
, and your SpeedDial
will remain open.因此,不要在onClick
设置此状态,您的SpeedDial
将保持打开状态。 :) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.