Fixes https://gitlab.com/kicad/code/kicad/issues/12505 (cherry picked from commit d96598c87c)
d96598c87c