JQuery Mobile 1.2.0 Popups navigate back too far on close (with Knockout JS?)

JQuery Mobile 1.2.0 Popups navigate back too far on close (with Knockout JS?)

I have hit an issue with JQuery Mobile 1.2.0 Popups on multipage app which causes incorrect navigation on return from the popup. The issue may be an interaction between Popups and data bound controls using Knockout-JS (2.1.0).

I am able to create a popup (clicking on a button) and the URL changes to add the hashtag "&ui-state=dialog" as it should. I close the popup and it returns to the underlying page apparently removing the hashtag from the URL as displayed in the browser navigation bar. So far this is all as expected. I then enter data into a bound control (doesn't matter what type of control - as long as it has the data-bind tag for Knockout-JS) navigate away from the input control and then popup (by user interaction) the same popup as before on the same page. This time the URL DOESN'T show the hashtag and when the Popup is closed the page is incorrectly navigated back one step in the history, losing anything entered on the page.

If I remove the binding to Knockout-JS, the problem doesn't seem to occur - although I can't see why the two libraries should be interacting. I then ran Jquery Mobile in debug mode and determined that what appears to be happening is that an extra entry is being created (or probably not removed) in the urlHistory.stack array, with the hashtag included, that remains on the return from the popup, even though the browser URL is showing as correct (ie Without the hashtag). I have worked around the issue by binding to the popupafterclose event and checking if the current active urlHistory.stack entry contains the "ui-state" hashtag and if it does, I pop it off the stack and step back one level in the history. This seems to at least partially resolve the issue, but I can't work out why the problem should be occurring in the first place or how the two libraries could be interacting to cause the issue - particularly as Knockout-JS is not even dependent on JQuery. Has anyone else seen this (with or without Knockout -JS) or have any idea what the underlying cause might be? I am also concerned that my urlHistory.stack is now wrong and that this will cause other navigation issues using back etc.