Skip to content

Commit

Permalink
fix(multiselet, dropdown): fix change detection on backdrop click
Browse files Browse the repository at this point in the history
  • Loading branch information
abalad committed Oct 27, 2020
1 parent e249acd commit 351acdc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>
<input readonly notform class="ui-hidden-input" [(ngModel)]="value">
<ng-template cdkConnectedOverlay
(backdropClick)="isOpen = false"
(backdropClick)="onBackdropClick()"
[cdkConnectedOverlayHasBackdrop]="true"
[cdkConnectedOverlayOrigin]="trigger"
[cdkConnectedOverlayBackdropClass]="'cdk-overlay-transparent-backdrop'"
Expand Down
5 changes: 5 additions & 0 deletions projects/truly-ui/src/components/dropdownlist/dropdownlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ export class TlDropDownList extends ValueAccessorBase<any> implements OnInit, On
}
}

onBackdropClick() {
this.isOpen = false;
this.changes.detectChanges();
}

private initializeComponent() {
this.setUpComponent();
this.validateData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>
</div>
<ng-template cdkConnectedOverlay
(backdropClick)="isOpen = false"
(backdropClick)="onBackdropClick()"
[cdkConnectedOverlayHasBackdrop]="true"
[cdkConnectedOverlayOrigin]="trigger"
[cdkConnectedOverlayBackdropClass]="'cdk-overlay-transparent-backdrop'"
Expand Down
5 changes: 5 additions & 0 deletions projects/truly-ui/src/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ export class TlMultiSelect extends ValueAccessorBase<any> implements OnInit, Aft
this.listenControlChanges();
}

onBackdropClick() {
this.isOpen = false;
this.change.detectChanges();
}

private listenControlChanges() {
this.subscription.add(this.control.valueChanges.subscribe(() => {
this.validateHasModel();
Expand Down
13 changes: 13 additions & 0 deletions src/app/components/form/modal/form-modal/form-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
<div class="spacer"></div>
<tl-panelgroup [labelGroup]="'Access Informations'">
<div class="form-group">
<div class="form-group">
<tl-multiselect
[data]="roles"
[labelTag]="'description'"
[label]="'Roles'"
[keyValue]="'id'"
[onlyKeyValue]="true"
[labelSize]="100"
formControlName="role"
[sortAlphabetically]="true"
[query]="'description'">
</tl-multiselect>
</div>
<div class="form-group">
<tl-input formControlName="user" showValidations [labelSize]="'100px'" [label]="'User'"></tl-input>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ import { Validators, FormGroup, FormControl } from '@angular/forms';
} )
export class FormModalComponent {

public roles = [
{ id: 1, description: 'Administrator'},
{ id: 2, description: 'Secretary'},
{ id: 3, description: 'Doctor'},
];

public form = new FormGroup({
name: new FormControl('', Validators.required),
nickname: new FormControl('', Validators.required),
email: new FormControl('', [Validators.email, Validators.required]),
description: new FormControl('', [Validators.required, Validators.minLength(8)]),
user: new FormControl('', Validators.required),
role: new FormControl('', Validators.required),
password: new FormControl('', [
Validators.required,
Validators.minLength(8)
Expand Down

0 comments on commit 351acdc

Please sign in to comment.