Escape the value of the hidden field holding the focused element id

(cherry picked from commit 149cc36f30bcd3b31b727941f701e12ecbe3440f)
(cherry picked from commit 849e0430730846048a512ea56689432ea0f2e067)