Reputation: 10927
I want to prevent onBlur event when I click on a specific element:
<input type="text" onBlur={<call when I click outside of element except when I click on a specific element>} />
Upvotes: 6
Views: 2474
Reputation: 391
What you could do is give the element that would stop the call an ID and then check for that ID via event.relatedTarget.id
const doSomething = (event) => {
if(event.relatedTarget.id === "badButton"){
return
}
//Do things
}
return(
<div className="DashboardHeader" onBlur={(e) => doSomething(e)}>
<button id="badButton">newbutton</button>
</div>
)
Upvotes: 6