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

addEventListener lost after ViewTransition enabled #7982

Closed
1 task
dehbini opened this issue Aug 7, 2023 · 1 comment
Closed
1 task

addEventListener lost after ViewTransition enabled #7982

dehbini opened this issue Aug 7, 2023 · 1 comment
Labels
needs triage Issue needs to be triaged

Comments

@dehbini
Copy link

dehbini commented Aug 7, 2023

What version of astro are you using?

2.10.1

Are you using an SSR adapter? If so, which one?

Node

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

I added some click eventListener to navigation bar. After enabling ViewTransition, the click listener works only on first page load, after navigating to another page, I lost the click event on those elements.

What's the expected result?

If I add el.addEventListener('click', someFunc) to some elements, and those elements are in DOM even after navigating to other pages, the event should still work.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-stfdbe-97paz7?file=src%2Fpages%2Findex.astro,src%2Fpages%2Ftwo.astro,src%2Fcomponents%2FLayout.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 7, 2023
@natemoo-re
Copy link
Member

This is by design. You can use the transition:persist directive or listen for the astro:load event to handle behavior across page navigations.

@natemoo-re natemoo-re closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants