Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicating DOM elements with before and after turbo streams actions #1288

Open
ExceLLent404 opened this issue Jul 24, 2024 · 0 comments · May be fixed by #1290
Open

Duplicating DOM elements with before and after turbo streams actions #1288

ExceLLent404 opened this issue Jul 24, 2024 · 0 comments · May be fixed by #1290

Comments

@ExceLLent404
Copy link

The problem is similar to what #240 solved for append and prepend actions. But not for before and after actions.

Streams reference for append action says:

If the template’s first element has an id that is already used by a direct child inside the container targeted by dom_id, it is replaced instead of appended.

The same for prepend.

However, the described behavior does not apply to the before and after actions.

The problem:

Assuming there is the following HTML

<div id="top"></div>
<div id="middle"></div>
<div id="bottom"></div>

then such turbo stream element with before action

<turbo-stream action="before" target="bottom">
  <template>
      <div id="middle"></div>
  </template>
</turbo-stream>

or with after action

<turbo-stream action="after" target="top">
  <template>
      <div id="middle"></div>
  </template>
</turbo-stream>

will produce DOM with elements with duplicated id

<div id="top"></div>
<div id="middle"></div>
<div id="middle"></div>
<div id="bottom"></div>
tpaulshippy added a commit to tpaulshippy/turbo that referenced this issue Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant