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.

nested frames with a form will not redirect

See original GitHub issue

Given I have a template that looks like this:

<%= turbo_frame_tag 'modal_thing' do %>
  <%= turbo_frame_tag 'create_tag', target: '_top' do %>
    <%= form_with url: '/bags/1', method: 'patch' do |form| %>
      <input name="title">
      <button type="submit">go</button>
    <% end %>
  <% end %>
<% end %>

And my server responds with a 302 redirect.

Then the page does not redirect on form submission and I see this error in the javascript console:

Response has no matching <turbo-frame id="modal_thing"> element turbo.es2017-esm.js:5181
    _callee25$ turbo.es2017-esm.js:5181
    Babel 8
    _callee22$ turbo.es2017-esm.js:4906
    Babel 10
    formSubmissionSucceededWithResponse turbo.es2017-esm.js:5065
    requestSucceededWithResponse turbo.es2017-esm.js:1048
    _callee2$ turbo.es2017-esm.js:616
    Babel 8
    _callee$ turbo.es2017-esm.js:559
    Babel 12
    _callee4$ turbo.es2017-esm.js:972
    Babel 8
    formSubmissionIntercepted turbo.es2017-esm.js:4992
    submitBubbled turbo.es2017-esm.js:1214
    (Async: EventListener.handleEvent)
    start turbo.es2017-esm.js:1226
    connect turbo.es2017-esm.js:4785
    connectedCallback turbo.es2017-esm.js:143
    (Async: LifecycleConnectedCallback)
    js turbo.es2017-esm.js:5621
    Webpack 9

If I remove the outer containing turbo-frame, then it works as expected.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
boardfishcommented, Sep 17, 2021

I’ve been having exactly the same problem. I’ve tried applying target="_top" to the form, the inner frame, and the outer frame.

If target: '_top' is applied to the inner frame and/or the form, the error refers to the outer frame as in the OP.

If target: '_top' is applied to both frames and the form, the error reads Response has no matching <turbo-frame id="\39 modal_thing"> element.

0reactions
boardfishcommented, Sep 28, 2021

Thanks for the fix, @tleish and co.!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Form target be nested frame? - html - Stack Overflow
Purpose is to submit form's content(post) to php file, but the result to be loaded in this same file(if it would be a...
Read more >
Response.redirect from a frameset. - MSDN - Microsoft
i want the entire frameset to be redirected. target="_top" within a link tag causes the new page to load in the full body...
Read more >
Prevent redirects from breaking out of iframe | Community
When form A ends the redirect opens in the parent window and not within the iframe. The entire form sequence remains within the...
Read more >
Redirect to new page on successful form submission ... - GitHub
I'm trying to figure out how to do this. Right now, when I submit a form from within a turbo_frame_tag , I'm reliant...
Read more >
Solved: Redirecting a form on load - ServiceNow Community
This is not a problem except that It loads another set of frames nested within the existing frame - including another copy of...
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