【发布时间】:2018-08-23 19:56:46
【问题描述】:
我正在使用 Material-ui 中的 Button 构建一个反应应用程序。我希望能够拖放包含按钮的组件。对于拖放功能,我使用的是 react-sortable-hoc。当按钮中没有内容时,按钮可以正常工作,但是当按钮包含任何内容时,例如下面代码中的图标,a 会呈现在不允许您单击按钮的按钮上。但是,可以单击 边缘上方或下方的按钮,并且该按钮会记录它已被单击。我无法确定为什么图标会阻止按钮注册它被点击的事实。
这是 ComponentContainingButton 中按钮的代码。
<FormControl>
<Button onClick={e => handleButtonClick(e, currentIndex)}>
<DeleteIcon />
</Button>
</FormControl>
这里是渲染 ComponentContainingButton 的代码。
const SortableItem = SortableElement((props) => {
const {
handleButtonClick
currentIndex,
} = props;
return (
<div className="box">
<TravelSingleLeg
handleButtonClick={handleButtonClick}
currentIndex={currentIndex}
/>
</div>
);
});
const SortableList = SortableContainer((props) => {
const {
items,
handleButtonClick
} = props;
return (
<div>
{items.map((value, index) => {
const identifier = `item-${index}`;
return (
<div>
<SortableItem
key={identifier}
index={index}
currentIndex={index}
handleButtonClick={handleButtonClick}
/>
</div>
);
})}
</div>
);
});
您能给我的任何帮助将不胜感激。
【问题讨论】:
标签: reactjs material-ui react-sortable-hoc