Created by: jgregory-apogee
Fixes #12992 . Please see that issue for the problem description and a reproducible example including the fix.
I wasn't able to get the automated test suite running locally, so I haven't added any tests for this. But I'd be happy to add them if someone can point me in the right direction.