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

Fixed theme switching bug related to page transitions. #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AbarcaJ
Copy link

@AbarcaJ AbarcaJ commented Apr 7, 2024

Issue ref: #46

  • [+] Se agregó transition:persist para indicar a Astro que mantenga el estado entre transiciones a los botones/dropdown de la funcionalidad de cambio de tema.
  • [+] Se agregó un eventListener astro:after-swap que ayudará a refrescar el tema luego de una Transición entre páginas/ruta, debido a que en ciertas ocasiones no solo los botones se rompen, si no que el tema no se actualiza.
  • [+] Adicionalmente movemos el scroll hasta arriba al cambiar de página/ruta para mostrar el contenido desde el inicio.

Motivo del bug:
El problema ocurre debido a las <ViewTransitions/> de Astro, justo al momento de redireccionar a otra página/ruta mediante un anchor tag.

Finalmente:
Ofrezco esta solución ya qué experimenté el mismo problema en mi porfolio incluso sin tener un Dropdown y solo ser un botón de ThemeToggle.

Espero sea de ayuda!

Copy link

netlify bot commented Apr 7, 2024

Deploy Preview for animated-churros-60739d ready!

Name Link
🔨 Latest commit eb78541
🔍 Latest deploy log https://app.netlify.com/sites/animated-churros-60739d/deploys/6612067c4f0c6d0008ad5f84
😎 Deploy Preview https://deploy-preview-54--animated-churros-60739d.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants