Stop clicks on UI from affecting the game

I found out about _UnhandledInput and it seems to be what I need but I can't quite figure out how to properly use it. In my player state class I check for ability key presses with _UnhandledInput but it still goes through even when mouse filter on ui is set to stop

Here is my character input handling code:

public override void _UnhandledInput(InputEvent )
{
  foreach (var ability in Abilities)
  {
    if (@event.IsActionPressed(ability.Key))
    {
      HandleAbility(ability.Value);
      return;
    }
  }
}

Here is my main scene tree:

Main scene tree

UI is instanced in Managers scene under Canvas Layer node

Here is my UI setup. Mouse Filter is set to stop:

UI setup

Yet when I instantiate UI in the main scene and click on it, it still triggers left mouse button event in character class and handles it. What am I doing wrong?

EDIT: Problem found, UnhandledInput was working as expected, apparently I didn't move all input logic there so it was triggered from outside