Fix a bug in substitution mutation context menu

[#41660503]

Dynamically added classes weren't removed correctly, so after a few
substitution mutations submenu elements were invisible.