Back port of https://github.com/jmix-framework/jmix/issues/5022
Back port of #5022