Re-add "Pull in bugfix from upstream for WEB-11626"

This reverts commit 109696fd9b9a4fab4f714a42fe65588989286b1a.