#5952 - fix infinite loop when disabling > 50 annotations or metadata

Replaces #6121