Fixes https://gitlab.com/kicad/code/kicad/-/issues/21707 (cherry picked from commit 37df36be62)
37df36be62