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

Editor: make use of minCharCount and clearOnSelection of autocomplete component #1036

Merged
merged 9 commits into from
Dec 12, 2024
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', () => {
tkohr marked this conversation as resolved.
Show resolved Hide resolved
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"
tkohr marked this conversation as resolved.
Show resolved Hide resolved
[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('')
tkohr marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Loading