Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Returning context back to a non-Turbolinks Component view reloads the view #81

@vitchell

Description

@vitchell

I'm not an expert at mobile development or Turbolinks-mobile so I'll try and keep this simple without injecting too much:

I'm loading a component view that contains a WebView that is not directly tied to the global Turbolinks context. In that webview, I'd like to upload a file. When I click the file input form field and select an image from the native image picker, once context is passed back upon selection, this causes the entire Turbolinks context to reload, resetting the nav stack and losing the file that was just selected. This does not happen if you use Turbolinks.visit to load the URL - only if I'm inside a Component that has a WebView that is not using Turbolinks.visit.

If I do the same thing inside a Modal view, the underlying parent context correctly stays the same, but the modal view where the event originated from gets reset back to its starting point.

I can verify that the underlying Component's WebView does actually regain focus for a moment - if I use the file picker, the underlying WebView can see and process the file that was chosen very briefly. But the stack resets almost immediately, which causes various problems. AFAIK this is a full reloading of the component, so the component state can't be used to address this as it gets reset in the process as well.

If I use some other thing like a third party file picker or a custom component of my own creation, the same thing happens - once context/focus is returned back to the RNTurbolinks app, the currently active Turbolinks app or modal resets to its base state. Its not just the default webview filepicker.

I see 3 possible solutions to this. I don't know how do-able any of them actually are:

  • Stop this from happening. When the app regains focus, I wouldn't expect the nav stack to get completely reset in this way, even if I'm in a Component. I know this doesn't happen if you're viewing a URL instead of a Component.
  • Make it configurable - if there's a good reason for this to happen, maybe there's a way to make configurable so that it can be skipped?
  • Make it so that modals can open URLs directly with the Turbolinks context instead of requiring a Component. This one is just speaking to my personal use case so I don't think its necessarily the best solution. But at least theoretically, this would solve my problem.

I can provide some code to reproduce if necessary, though I think it's probably pretty straightforward given the description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions