OnPointerEnter and Exit Not Working After Mouse Click

Hello,
There is a structure of flipping an image horizontally and vertically. There are 4 game objects in my scene. First one is a button for horizontal flip, the second one is for vertical flip, and third one is the image. I try to hide these two buttons until user hovers over the image. When hovered, buttons become active. The fourth game object is parent for all three in order to not lose buttons visibility when hovering them to click. That way whether cursor over buttons or image it is still over parent game object so works fine.
The problem is when I click these buttons, buttons disappear abruptly and OnPointerEnter stops working. Basically it cancels something.

Here is the code. It is attached to the parent object.

using UnityEngine;
using UnityEngine.EventSystems;

public class ButtonController : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public GameObject vert, horz;

    public void OnPointerEnter(PointerEventData eventData)
    {
        if (vert != null && horz != null)
        {
            vert.SetActive(true);
            horz.SetActive(true);
        }
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        if (vert != null && horz != null)
        {
            vert.SetActive(false);
            horz.SetActive(false);
        }
    }
}

This is the code for flipping. It is attached to button objects.

using UnityEngine;

public class FlipController : MonoBehaviour
{
    public GameObject mapPiece;

    public void FlipHorizontal()
    {
        Vector3 targetAngles = mapPiece.transform.eulerAngles + 180f * Vector3.right;
        mapPiece.transform.eulerAngles = targetAngles;
    }

    public void FlipVertical()
    {
        Vector3 targetAngles = mapPiece.transform.eulerAngles + 180f * Vector3.up;
        mapPiece.transform.eulerAngles = targetAngles;
    }
}

Thanks in advance for the answers.

If you are using OnPointerEnter Or OnPointerExit it works differently on pc and on mobile differently. On pc if you drag your cursor to the object the OnPointerEnter works automatically no need to click it but on mobile When you click the object then it works. Same with OnPointerExit.

Hi,
I couldn’t be able to explain myself very well. When hover, flip buttons appear. Normally, these are not visible. When appears and click one of them, something breaks. Buttons disappear and OnPointEnter stop working.

Screenshot 2024-02-14 154219

Here you can see two buttons. When I click one of them, everything stop working.