Skip to content

updateQueryString doesn't work with shinylive #4153

@willgearty

Description

@willgearty

updateQueryString() (or session$updateQueryString) ultimately calls window.history.replaceState() or window.history.pushState(). However, when using shinylive the app is served as an iframe, so window in this case refers to the iframe, not the parent window. Therefore, neither of these calls works and updateQueryString() does nothing. I've found the following works instead:

shinyjs::runjs(paste0("window.parent.history.pushState(null, null, '", pushQueryString, "')"))

The MDN docs state that "If a window does not have a parent, its parent property is a reference to itself." Therefore. changing the typescript code to just use window.parent instead of window should fix this problem, regardless of whether you are using shinylive or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions