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

SSR Duplicate elements with provideClientHydration() #14569

Closed
kyjus25 opened this issue Jan 16, 2024 · 4 comments
Closed

SSR Duplicate elements with provideClientHydration() #14569

kyjus25 opened this issue Jan 16, 2024 · 4 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@kyjus25
Copy link
Contributor

kyjus25 commented Jan 16, 2024

Describe the bug

Using the pButton directive or p-carousel with a set autoplayInterval causes duplicate PrimeNG elements to render. There are most likely more scenarios where this is an issue but I am noting what we have found for others.

pButton Menu Carousel
Screenshot 2024-01-16 at 3 49 54 PM Screenshot 2024-01-16 at 4 41 21 PM Screenshot 2024-01-16 at 4 42 08 PM

Update: Occurs when provideClientHydration() is enabled, and occurs on a fresh load (does not happen on subsequent client-side navigation)

Possibly related: angular/angular#50543

Environment

Occurs on Angular CLI with application builder & Analog when provideClientHydration() is enabled

Reproducer

No response

Angular version

17.0.0 - 17.0.9

PrimeNG version

17.3.2

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18

Browser(s)

No response

Steps to reproduce the behavior

  • ng new primeng-test --ssr
  • Include Lara blue and primeicons
  • <button pButton label="Join Now" icon="pi pi-discord"></button> (note pButton, not p-button)

Expected behavior

Only 1 icon and 1 label to render

@kyjus25 kyjus25 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 16, 2024
@kyjus25 kyjus25 changed the title SSR Duplicate elements SSR Duplicate elements with provideClientHydration() Jan 16, 2024
@cetincakiroglu cetincakiroglu self-assigned this Jan 17, 2024
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jan 17, 2024
@cetincakiroglu cetincakiroglu added this to the 17.3.3 milestone Jan 17, 2024
@kyjus25
Copy link
Contributor Author

kyjus25 commented Jan 18, 2024

@cetincakiroglu Button was only one of the places I found the issue. Menu, Carousel, and the doc code examples themselves also exhibited duplicate elements, but I didn't check extensively thru every component

Unfortunately this only occurs on a fresh page load when hydration takes place, subsequent client side navigation works as a typical SPA would and does not duplicate elements, so it's a little tedious to track down. Probably each component would need to be routed and checked with a fresh page load for anything that looks sus

@cetincakiroglu
Copy link
Contributor

Thanks a lot for letting me know, I'll check the rest and need to find an extended solution to apply several places.

@echotech11
Copy link

The galleria / carousel also have this issue.
ng serve:
Screenshot 2024-01-16 at 14-59-50 Aim Base Home

ng run app:serve-ssr:
Screenshot 2024-01-16 at 14-59-26 Aim Base Home

@cetincakiroglu
Copy link
Contributor

Hi all,

Those experiencing this issue can solve the problem of multiple rendering of the relevant components by using ngSkipHydration . This issue is related to Angular's own template components and is beyond our scope of intervention. You can use this workaround temporarily until the Angular team fixes the issue. For more information, please visit https://angular.dev/guide/hydration#how-to-skip-hydration-for-particular-components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants