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

fix: check includes on init and known reference issues #516

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/young-buttons-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/ui": patch
---

fix: check includes on init and known reference issues
3 changes: 1 addition & 2 deletions src/anchor/anchor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
import { buildBem, isTemplateRef, last } from '../utils';

import { AnchorDirectiveChild } from './anchor.directive';
import { AnchorModule } from './anchor.module';
import { AnchorItem, AnchorTreeItem } from './types';
import { getAnchorTreeItems } from './utils';

Expand All @@ -38,7 +37,7 @@ const bem = buildBem('aui-anchor');
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [NgFor, NgIf, NgTemplateOutlet, AnchorModule],
imports: [NgFor, NgIf, NgTemplateOutlet],
})
export class AnchorTreeComponent
extends AnchorDirectiveChild
Expand Down
8 changes: 1 addition & 7 deletions src/paginator/paginator.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { SelectComponent } from '../select/select.component';

import { PaginatorComponent } from './paginator.component';

describe('PaginatorComponent', () => {
Expand Down Expand Up @@ -116,11 +114,7 @@ describe('PaginatorComponent', () => {
</aui-paginator>
`,
standalone: true,
imports: [
PaginatorComponent,
// https://github.com/angular/angular/issues/51568
SelectComponent,
],
imports: [PaginatorComponent],
})
class TestComponent {
currentPage = 1;
Expand Down
5 changes: 3 additions & 2 deletions src/select/base-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
QueryList,
ViewChild,
ViewChildren,
forwardRef,
} from '@angular/core';
import {
BehaviorSubject,
Expand Down Expand Up @@ -143,10 +144,10 @@ export abstract class BaseSelect<T, V = T>
@ContentChild(OptionContentDirective)
protected optionContent?: OptionContentDirective;

@ViewChildren(OptionComponent)
@ViewChildren(forwardRef(() => OptionComponent))
customOptions: QueryList<OptionComponent<T>>;

@ContentChildren(OptionComponent, { descendants: true })
@ContentChildren(forwardRef(() => OptionComponent), { descendants: true })
contentOptions: QueryList<OptionComponent<T>>;

isTemplateRef = isTemplateRef;
Expand Down
14 changes: 8 additions & 6 deletions src/select/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
Validator,
ValidatorFn,
} from '@angular/forms';
import { startWith } from 'rxjs';

import { coerceAttrBoolean } from '../utils';

import { SelectComponent } from './select.component';
import { TrackFn } from './select.types';

// @dynamic
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class AuiSelectValidators {
static includes<T>(
Expand Down Expand Up @@ -64,11 +64,13 @@ export class IncludesDirective<T> implements Validator, AfterContentInit {
constructor(private readonly selectRef: SelectComponent<T>) {}

ngAfterContentInit() {
this.selectRef.contentOptions.changes.subscribe(() => {
if (this.onValidatorChange) {
this.onValidatorChange();
}
});
this.selectRef.contentOptions.changes
.pipe(startWith(this.selectRef.contentOptions))
.subscribe(() => {
if (this.onValidatorChange) {
this.onValidatorChange();
}
});
}

registerOnValidatorChange(fn: () => void) {
Expand Down
Loading