Filter Bar Toggle Works in Button in Menu Button But Not in Button on Toolbar

I have the following code:


It toggles the filter bar on and off when it is in a button that is within a menu button. When I copy that button to a toolbar, it no longer toggles. The button only turns on the filter bar but no longer turns it off. Ideas? TIA

I tried here and inside a menu button it has the same behavior as outside it. I would also like to have a button to show/hide the filter bar, but normally it is either always shown, or only shown when there is a filter. I don't know if that purpose can be achieved by means of a script.