Patches provided by Joel Baker in PR 22269, verified by myself.
restored by compiling with NO_PREVIEW defined.