This restores some changes from https://github.com/grafana/grafana/pull/61920 that were accidentally deleted.