virtual-dom icon indicating copy to clipboard operation
virtual-dom copied to clipboard

Browser.Navigation.pushUrl to come after DOM update

Open dbdbdb opened this issue 6 years ago • 0 comments

In a single page application when a link is clicked you get a call to

onUrlChange : Url -> msg

and the message is sent to

update : msg -> model -> ( model, Cmd msg )

In the update you typically return a Browser.Navigation.pushUrl command.

If you have a filled in password input field on the page then the pushUrl command (when executed) triggers a save password dialog in the browser. I only want the browser to save the password when the user submit the password, not when he/she clicks a link to leave the page that has the password on it.

One need to clear the password in the DOM before the Browser.Navigation.pushUrl command is executed. Returning a new model with the password being an empty string does not work since the pushUrl command is executed before the model is rendered into the dom.

I've solved it by using a port and doing all the history manipulation there. It's however fairly complicated even then to get the ordering of DOM updates and history updates in sync.

This is similar to the cases in issue #108, but not exactly the same.

dbdbdb avatar Mar 30 '19 19:03 dbdbdb