The class name handling for validation inadvertently added `undefined` as a class when validation is not used. This rearranges the logic to avoid the issue. Fixes https://github.com/vector-im/riot-web/issues/9345