Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ describe('DotKeyValueTableHeaderRowComponent', () => {
expect(spectator.query('small.text-red-500')).toHaveText('Key already exists');
});

it('should clear duplicate key error when the conflicting key is removed from forbiddenkeys', () => {
spectator.component.keyControl.setValue('name');
spectator.component.keyControl.markAsDirty();
spectator.detectChanges();

expect(spectator.component.keyControl.hasError('duplicatedKey')).toBeTruthy();

spectator.setInput('forbiddenkeys', {});
spectator.flushEffects();
spectator.detectChanges();

expect(spectator.component.keyControl.hasError('duplicatedKey')).toBeFalsy();
expect(spectator.component.keyControl.errors).toBeNull();
});

it('should invalidate form when value is empty', () => {
spectator.component.valueControl.setValue('');
spectator.component.valueControl.markAsDirty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, input, output, viewChild, inject } from '@angular/core';
import { Component, ElementRef, effect, input, output, viewChild, inject } from '@angular/core';
import {
AbstractControl,
FormsModule,
Expand Down Expand Up @@ -61,6 +61,13 @@ export class DotKeyValueTableHeaderRowComponent {
hidden: [false]
});

constructor() {
effect(() => {
this.$forbiddenkeys();
this.keyControl.updateValueAndValidity({ emitEvent: false });
});
}

/** Gets the key form control */
get keyControl() {
return this.form.controls.key;
Expand Down
Loading