I want to be able to just do a click event on only the image, but because I have to set width and height, its setting a click event on the entire parent div.
for example, if the image is 600 width by 300 height, where there's space between the parent the click event is still happening outside the image but within the parent.
<div
style={{ width: 600, height: 600 }}
className="image-item bg-gray-200 w-9/12 h-auto relative"
>
<div
onClick={(e) => handleTags(e)}
className=""
ref={imageWrapRef}
>
<Image
className=""
src={image["data_url"]}
alt=""
layout="fill"
objectFit="contain"
/>
</div>
</div>
The space above and below the image are still clickable, but I just want to click on the image only.
Screenshot of inspector element of the produced code:
Here's a working codesandbox as well: https://codesandbox.io/s/proud-rain-d51sv?file=/pages/index.js