Skip to content

Back button is not working for turbo advance targeting a frame when rendered inside rails #1300

@keithschacht

Description

@keithschacht

I have a really hard bug that I've finally stripped down to an essential repro of it. I can't figure out what's going on.

What the user experiences on my app is:

  1. Click a link which targets a turbo-frame on the page with action="advance"
  2. The contents of the turbo-frame updates and the URL successfully changes
  3. Clicking the back button changes the URL back to what it was before, but it does not revert the contents

It's a bad bug because it feels like the back button is broken, which, of course, we want turbo to respect back behavior.

In order to file a bug report, I tried to create a failing test case within this hotwired/turbo.js project. I opened src/tests/fixtures/frames.html and set up the test situation did the usual yarn build; yarn start. Oddly, the back button worked properly. I could not initially repro it.

Puzzled, I copied the exact same contents of frames.html over to my rails project and the bug appears! I could not figure out what the difference is since I stripped everything down. The only difference is that one is being served by yarn server and one is being served by rails server and rendering view templates. Then I copied these same files into the rails public/ directory and the bug goes away! For some reason this bug is only present when html & javascript code is served up through rails views. I'm baffled.

I know this is confusing so try watching this video where I show it very simply:
https://share.zight.com/o0uAplQJ

And here is a repository with of a fresh rails app with just the 4 files needed to reproduce it, everything else has been stripped out. Pull this repo and you can try for yourself what I just demonstrated in the video:
https://github.com/krschacht/hotwire-demo

Metadata

Metadata

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