Revert "Revert "Merge pull request #11777 from evanxd/bug-863999""

This reverts commit 9ba0340e02fb857374b390b5ac59bbcd7557dc59.