最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I disable the Material-UI SpeedDial mouseover event - Stack Overflow

programmeradmin4浏览0评论

I am wanting to disable the default mouseover/hover behaviour of Material-UI's SpeedDial ponent (/). Currently when you mouseover the primary icon, the SpeedDial ponent will open. It will also open on click. This has caused issues with some of our users as when they mouse over the button - it opens - and they immediately click and it closes.

I would like to keep the just the click action for opening the SpeedDial for touch screen devices.

Is there a simple way for me to disable the hover/mouseover event? As far as I can tell the API does not allow this.

Thanks!

I am wanting to disable the default mouseover/hover behaviour of Material-UI's SpeedDial ponent (https://material-ui./api/speed-dial/). Currently when you mouseover the primary icon, the SpeedDial ponent will open. It will also open on click. This has caused issues with some of our users as when they mouse over the button - it opens - and they immediately click and it closes.

I would like to keep the just the click action for opening the SpeedDial for touch screen devices.

Is there a simple way for me to disable the hover/mouseover event? As far as I can tell the API does not allow this.

Thanks!

Share Improve this question asked Nov 27, 2019 at 22:24 OJJOJJ 1231 silver badge11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 20

This behaviour can be achieved by ignoring onOpen prop and control the ponent with onClick prop.

// Component code

const [open, setOpen] = React.useState(false);

const handleOpen = (event) => {
  setOpen(!open);
};

return (
   <SpeedDial
      onClick={handleOpen}
      open={open}
      ...
   />
);

You can see a working example here: https://codesandbox.io/s/material-demo-1lwci

发布评论

评论列表(0)

  1. 暂无评论