[APM] Fix custom link filter select value (#137025)

* [APM] Fix custom link filters to clear values after selecting field (#126066)

* adds line comment

* adds e2e test to validate the fix
This commit is contained in:
Oliver Gupte 2022-07-25 11:16:28 -04:00 committed by GitHub
parent b8b57d530d
commit bd5abb1c80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -34,4 +34,17 @@ describe('Custom links', () => {
cy.get('[data-test-subj="editCustomLink"]').click();
cy.contains('Delete').click();
});
it('clears filter values when field is selected', () => {
cy.visit(basePath);
cy.contains('Create custom link').click();
cy.get('[data-test-subj="filter-0"]').select('service.name');
cy.get(
'[data-test-subj="service.name.value"] [data-test-subj="comboBoxSearchInput"]'
).type('foo');
cy.get('[data-test-subj="filter-0"]').select('service.environment');
cy.get(
'[data-test-subj="service.environment.value"] [data-test-subj="comboBoxInput"]'
).should('not.contain', 'foo');
});
});

View file

@ -108,7 +108,8 @@ export function FiltersSection({
}
)}
onChange={(e) =>
onChangeFilter(e.target.value as FilterKey, value, idx)
// set value to empty string to reset value when new field is selected
onChangeFilter(e.target.value as FilterKey, '', idx)
}
isInvalid={
!isEmpty(value) &&
@ -118,6 +119,7 @@ export function FiltersSection({
</EuiFlexItem>
<EuiFlexItem>
<SuggestionsSelect
key={key}
dataTestSubj={`${key}.value`}
fieldName={key}
placeholder={i18n.translate(