I wonder how is possible to have button inside NextJS Link component? When you wrap the button by and click the button, then it run onClick event and after it redirect to value in href attribute.
How can you just run onClick button event and stop redirecting?
<Link href={`./${school.attributes.Slug}/obor/${field.attributes.Code}`}>
<div className="responsive-table__row">
<div className="responsive-table__item">50</div>
<div className="responsive-table__item">40/50</div>
<div className="responsive-table__item">Test</div>
<div className="responsive-table__item">
<button className="responsive-table__button button button--secondary" onClick={() => handleModalOpenerClick(field)}>Show modal</button>
</div>
</div>
</Link>
Change your onClick handler to this:
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
handleModalOpenerClick(field);
}}
and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With