Move disabling code to addOptionItem. Fix disabling logic in checkbox menu items and template. Fixes #17399.