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

🐞 - Dropdown triggers change detection too frequently #8725

Closed
2 of 9 tasks
nsbarsukov opened this issue Aug 28, 2024 · 3 comments · Fixed by #8738
Closed
2 of 9 tasks

🐞 - Dropdown triggers change detection too frequently #8725

nsbarsukov opened this issue Aug 28, 2024 · 3 comments · Fixed by #8738
Assignees
Labels
P1 This issue has high priority

Comments

@nsbarsukov
Copy link
Member

Playground Link

https://stackblitz.com/edit/dropdown-triggers-cd-too-frequently?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.template.html

Description

app.component.ts
import { ChangeDetectionStrategy, Component, DoCheck } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { TuiDropdown, TuiLabel } from '@taiga-ui/core';
import { TuiSwitch } from '@taiga-ui/kit';

@Component({
  standalone: true,
  selector: 'app',
  templateUrl: './app.template.html',
  styleUrls: ['./app.style.less'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [FormsModule, TuiSwitch, TuiLabel, TuiDropdown],
})
export class App implements DoCheck {
  open = false;

  ngDoCheck() {
    console.log('=[tick]=');
  }
}
app.template.html
<label tuiLabel>
  <input tuiSwitch type="checkbox" [(ngModel)]="open" />
  Show dropdown
</label>

<p
  class="host"
  tuiDropdownDirection="bottom"
  [tuiDropdown]="dropdownContent"
  [tuiDropdownManual]="open"
>
  Dropdown host
</p>

<ng-template #dropdownContent>
  Taiga UI is fully-treeshakable Angular UI Kit consisting of multiple base
  libraries and several add-ons. It is based on ng-polymorpheus dynamic content
  approach and uses Web APIs for Angular for required browser APIs.
</ng-template>
dropdown-bug.mov

Angular version

18

Taiga UI version

4.4.1

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android
@splincode splincode added P1 This issue has high priority and removed state: need triage labels Aug 28, 2024
@splincode
Copy link
Member

@nsbarsukov
image

What if I comment out this line, the error will continue? I recently encountered this problem, and my guesses led to this code

image

@nsbarsukov
Copy link
Member Author

@splincode I've tried to comment this line – no infinite logs more.

So, these line cause cyclic change detection

@splincode
Copy link
Member

splincode commented Aug 28, 2024

Possible related issues: #8567 #8652

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 This issue has high priority
Development

Successfully merging a pull request may close this issue.

2 participants