Fix custom grains override

Fixes #14863.