Consider this component:
<Card onClick={openWindowHandler}>
<Editable onDoubleClick={enableInputHandler} />
</Card>
I want to achieve to stop event propagation only when the onDoubleClick event is dispatched, so the openWindowHandler function is not called. However, onClick will fire before onDoubleClick!
I can tell which type of event is being fired using the _.debounce function, but by this time the event has already been dispatched, so there is no way to call stopPropagation ().
class App extends React.Component {
delayedCallback = _.debounce(function (event) {
if (event.type === 'dblclick') {
} else {
}
}, 250)
handleClick = (event) => {
event.persist()
this.delayedCallback(event)
}
render () {
return (
<Card onClick={this.handleClick}>
<Editable onDoubleClick={this.handleClick} />
</Card>
)
}
}
Is there any way to do this?
EDIT: A
single click on an item <Editable />should be flagged by the parents calling openWindowHandler.