Is there a way to trigger a click event only on the image itself, rather than the entire parent div? When setting width and height for the parent div, the click event seems to encompass the entire area.
For instance, if the image is 600 pixels wide by 300 pixels high, clicking outside the image but within the parent still triggers the click event.
<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>
https://i.sstatic.net/azn52.jpg
Even though there is space above and below the image, those areas remain clickable. I just want the click action to apply to the image only.
Here's a screenshot of the inspected element in the code:
https://i.sstatic.net/kIGXn.png
You can also view a functional codesandbox here: https://codesandbox.io/s/proud-rain-d51sv?file=/pages/index.js