[f21/master] Fix switching environments when no environment is selected (#1018226)