Skip to content

Commit

Permalink
Merge pull request #1036 from geonetwork/ME-extend-autocomplete-to-cl…
Browse files Browse the repository at this point in the history
…ear-input

Editor: make use of minCharCount and clearOnSelection of autocomplete component
  • Loading branch information
Angi-Kinas authored Dec 12, 2024
2 parents decc890 + e589636 commit a63d6d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
17 changes: 15 additions & 2 deletions apps/metadata-editor-e2e/src/e2e/edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ describe('editor form', () => {
.should('have.length', 0)
cy.get('gn-ui-form-field-spatial-extent')
.find('gn-ui-autocomplete')
.click()
.type('a')
cy.get('mat-option').eq(1).click()
cy.editor_publishAndReload()
cy.get('@saveStatus').should('eq', 'record_up_to_date')
Expand Down Expand Up @@ -629,7 +629,9 @@ describe('editor form', () => {
})
it('should add a keyword', () => {
cy.editor_wrapPreviousDraft()
cy.get('gn-ui-form-field-keywords').find('gn-ui-autocomplete').click()
cy.get('gn-ui-form-field-keywords')
.find('gn-ui-autocomplete')
.type('a')
cy.get('mat-option').first().click()
cy.editor_publishAndReload()
cy.get('@saveStatus').should('eq', 'record_up_to_date')
Expand All @@ -641,6 +643,17 @@ describe('editor form', () => {
.find('span')
.should('have.text', 'Addresses ')
})
it('should close the autocomplete and clear the input after selecting a keyword', () => {
cy.get('gn-ui-form-field-keywords')
.find('gn-ui-autocomplete')
.type('a')
cy.get('mat-option').first().click()
cy.get('mat-option').should('not.exist')
cy.get('gn-ui-form-field-keywords')
.find('gn-ui-autocomplete')
.find('input')
.should('have.value', '')
})
it('should delete a keyword', () => {
cy.editor_wrapPreviousDraft()
cy.get('gn-ui-form-field-keywords')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
[displayWithFn]="displayWithFn"
[action]="autoCompleteAction"
(itemSelected)="handleItemSelection($event)"
[preventCompleteOnSelection]="true"
[minCharacterCount]="0"
[preventCompleteOnSelection]="false"
[minCharacterCount]="1"
[allowSubmit]="false"
[clearOnSelection]="true"
></gn-ui-autocomplete>
<div class="flex gap-2 flex-wrap">
<gn-ui-badge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3 class="text-[16px] font-bold text-main mb-[12px]" translate>
*ngIf="disabled$ | async"
class="p-4 text-sm border border-primary bg-primary-lightest rounded-lg"
translate
data-testid="disabled-message"
data-test="disabled-message"
>
editor.record.form.field.draft.only.disabled
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export class AutocompleteComponent
}
if (this.clearOnSelection) {
this.inputRef.nativeElement.value = ''
this.control.setValue('')
}
}
}

0 comments on commit a63d6d0

Please sign in to comment.