question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can only interact with a turbo frame once?

See original GitHub issue

It’s probably something silly, but I couldn’t figure it out yet…

The problem: After interacting with a specific turboframe, I cannot interact with it again.

First off: the server response does contain the correct turbo-frame-id 😃

Further details:

I have a simple form to inline edit the title of an item. It works on all items on the list perfectly. I click edit, update, click save, and the change is reflected. However if I try to do this another time on the same item, it just doesn’t do anything. No errors. If I edit another untouched item, it works fine.

When I inspect the element after updating, it still has the turbo-frame-id provided in the responses, but somehow also added src which wasn’t returned by the server… I’m not sure if this is a potential clue?

See attached video that hope demonstrates this?

CleanShot 2021-04-17 at 09 07 32

using: turbo-rails gem 0.5.9, turbo-rails 7.0.0-beta.5, rails 6.0 with webpacker 5.2.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rockwellllcommented, Apr 30, 2021

well, i came up with this solution for now

import { Controller } from 'stimulus';

// there is a bug within turbo that dosent let you navigate
// from a frame more than once, to fix this you have to reset the frame
// src and all works. this is a monkey patch. to use it
// place it directly on a frame, data-controller="reset-frame-src"
// data-action="turbo:submit-end->reset-frame-src#reset"

export default class extends Controller {
    reset() {
        this.element.src = "";
    }
}

and i use it like so

turbo_frame_tag some-id,
                    data: {controller: 'reset-frame-src',
                           action: 'turbo:submit-end->reset-frame-src#reset'} 

this will reset the src only on form submits, and links will work as expected, for example clicking. a back button within the frame will work, but when a form submission completes, it resets the src.

0reactions
duleorloviccommented, Jul 16, 2021

The documentations says that POST should redirect, I’m not sure why GET should also use redirect ? My use case is to use GET request for showing in another frame <turbo-frame id='modal'></turbo-frame> <turbo-frame target="modal"><a href='posts/1/edit'>Edit</a></turbo-frame>. But OK, for now I’m using this hack to have redirection response

  def edit
      if params[:redirection_happens].blank?
        redirect_to edit_post_path(params[:id], redirection_happens: true)
      end
  end
Read more comments on GitHub >

github_iconTop Results From Across the Web

Decompose with Turbo Frames - Turbo Handbook
Turbo Frames decompose pages into independent contexts, which can be lazy-loaded and scope interaction.
Read more >
Turbo Frames Vs. Turbo Streams - Learn Ruby on Rails
Let's go over the differences between Turbo Frames and Turbo Streams. ... The first problem is we can only update one frame at...
Read more >
Navigating Outside a Turbo Frame - Medium
Turbo Frames, by default, only captures the part of the response that matches the ID of the Turbo Frame that the request came...
Read more >
The difference between Turbo Streams and Turbo Frames
Turbo Frames only manipulate themselves, and this manipulation is always an update. Turbo Streams, on the other hand, can manipulate any DOM ...
Read more >
Turbo Frames and Turbo Stream templates - Hotrails
Rules 3: A link can target another frame than the one it is directly nested in thanks to the data-turbo-frame data attribute. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found