Bug: Menu item enable templates aren't evaluated for the currently listed items

Currently, menu list item enable/disable seems to not be refreshed when you’re in the menu, only when you first enter it. For example, the below adds a new input item to the main menu which should only be enabled when some trivial variable is 1. When you first enter the menu and change the input to 1 (which updates the variable) you can see the name is updated, but the item still stays there even though the enable should be false. If you go back and then reopen the menu, you’ll see this menu item is no longer there.

[gcode_macro TEST]
variable_val: 0
gcode:

[menu __main __test]
name: {"test %d %f" % (menu.input, printer.toolhead.estimated_print_time)}
enable: {printer['gcode_macro TEST'].val == 0}
type: input
input: {printer['gcode_macro TEST'].val}
index: 1
input_min: 0
input_max: 1
input_step: 1
realtime: false
gcode:
    SET_GCODE_VARIABLE MACRO=TEST VARIABLE=val VALUE={menu.input|int}

Expected behaviour is that as soon as the enable template returns false, the item disappears. There’s potentially another case where the whole menu itself becomes disabled (not just one of the items you’re seeing) - in that case, it should force you back one level?

I had a squiz through menu.py but I’m hoping it’s something someone who knows the code could implement in 5 minutes …

I think that is the intended behavior.

I suspect the alternate behavior would be confusing for users and error prone. For example, if the user was trying to click on a particular menu item, but it disappeared on them, they might inadvertently click on a menu item they did not intend to click.

I don’t use these “lcd” menus on my printers, but my general understanding is that the “enable/disable” feature is intended to reduce clutter in the menus so that they aren’t filled with options that make little sense. I don’t think the intent was to somehow “prohibit” actions.

Cheers,
-Kevin