I posted question originally on stackoverflow with no luck.
Simply saying when I click on ui element to close the canvas then I have to click again on the webgl screen to take unity take back control of pointer. I am wondering if that is a unity bug?
Solution found.
Create new class that inherits from Button class and override OnPointerDown method.
public override void OnPointerDown(PointerEventData eventData)
{
base.OnPointerDown(eventData);
Cursor.lockState = CursorLockMode.Locked
}
This forum is for UI Toolkit, not Unity UI (uGUI).
Will move thread.