Disabling an ActionMap on cancel and a enabling on performed causes an infinite loop

I’m not really sure if it is a bug, but the behavior is odd at the very least.
I have an inventory that I want to only have open while a button is held down, and don’t want gameplay input while it is open. To do this I have two ActionMaps “Gameplay” and “UI”, both have an InputAction called “Inventory”.
When the “Gameplay” inventory action is performed I disable the “Gameplay” map and enable the “UI” map, then when the “UI” inventory action is canceled I disable the “UI” and enable the “Gameplay” map. Doing this causes an infinite loop.
Beyond that added a check to both to return once they had been called x number of times, and but debug.logs in to see what was happening. After the first “Gameplay” performed action, only the “UI” canceled action was called, I expected to see it pinging back and forth or something.

If this is the expected behavior, can you explain what is happening please?

This is some example code that will causes the infinite loop.

 private GameInput input;
   
void Start()
{
  input = new GameInput();
  input.Gameplay.Enable();
  input.Gameplay.Inventory.performed += OpenInventory;
  input.UI.Inventory.canceled += CloseInventory;
}

public void OpenInventory(InputAction.CallbackContext ctx)
{
  input.Gameplay.Disable();
  input.UI.Enable();
}

public void CloseInventory(InputAction.CallbackContext ctx)
{
  input.Gameplay.Enable();
  input.UI.Disable();
}

Is bug for sure, needs fixing on our side to probably defer enable/disable after we’re outside callbacks.
I think as a temporary measure you could do something like this on your side

private GameInput input;
private bool gameplayMapShouldBeEnabled;
private bool inventoryMapShouldBeEnabled;

void Start()
{
  gameplayMapShouldBeEnabled = true;
  input = new GameInput();
  input.Gameplay.Inventory.performed += OpenInventory;
  input.UI.Inventory.canceled += CloseInventory;
}

void OnUpdate()
{
  if (gameplayMapShouldBeEnabled != input.Gameplay.enabled)
  {
    if (gameplayMapShouldBeEnabled)
      input.Gameplay.Enable();
    else
      input.Gameplay.Disable();
  }
  if (inventoryMapShouldBeEnabled != input.Inventory.enabled)
  {
    if (inventoryMapShouldBeEnabled)
      input.UI.Enable();
    else
      input.UI.Disable();
  }
}

public void OpenInventory(InputAction.CallbackContext ctx)
{
  gameplayMapShouldBeEnabled = false;
  inventoryMapShouldBeEnabled = true;
}

public void CloseInventory(InputAction.CallbackContext ctx)
{
  gameplayMapShouldBeEnabled = true;
  inventoryMapShouldBeEnabled = false;
}

Would you mind to file a bug report and we will take it from there? Thanks a lot!