Skip to content

Commit

Permalink
modifs autocomplete + correction autocomplete.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Pourchel committed Feb 13, 2024
1 parent 5559682 commit b22ed32
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ describe('AutocompleteComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AutocompleteComponent ]
})
.compileComponents();
declarations: [AutocompleteComponent],
}).compileComponents();

fixture = TestBed.createComponent(AutocompleteComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ export class AutocompleteComponent {
@Input() acValue = '';
@Input() filteredList: Array<string> = [];
@Input() selectedValue = false;
@ViewChild('acInput') acInput!: ElementRef;
@ViewChild('acInput') acInput!: ElementRef<any>;

open(): void {
this.isOpen = !this.isOpen;
this.onChange;
}

close(): void {
setTimeout(() => {
if (this.selectedValue == false) {
// vérifier si acInput est vide pour que la scrollbar fonctionne
this.isOpen = true;
} else {
this.isOpen = false;
}, 300);
}
}

escClose(event: KeyboardEvent): void {
Expand All @@ -31,6 +34,31 @@ export class AutocompleteComponent {
}
}

navigationKeyDown(val: string) {
if (this.isOpen == true && this.selectedValue == true) {
//déplace le focus visuel vers la valeur suggérée suivante
}

this.acInput.nativeElement.value = val;
if (val == '' && this.isOpen == false) {
// déplace le focus visuel sur la première option
}
}

navigationKeyUp(val: string) {
if (this.isOpen == true && this.selectedValue == true) {
//déplace le focus visuel sur la dernière valeur suggérée
}

this.acInput.nativeElement.value = val;
if (val == '') {
if (this.isOpen == false) {
this.isOpen = true;
}
// déplace le focus visuel sur la dernière option
}
}

onChange(e: any) {
this.acValue = e.target.value;
this.filteredList = this.values.filter(value => value.toLowerCase().startsWith(this.acValue.toLowerCase()));
Expand Down

0 comments on commit b22ed32

Please sign in to comment.