mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
Adding ability to deselect EPM subcategory (#164260)
## Summary
Fixes #156419
If an EPM subcategory is selected, this PR makes it possible to deselect
that subcategory before deselecting the parent category by clicking on
the search bar button.
Behavior is shown in below video:
49e20b81
-1a3e-436e-8b94-af43a515eccf
### Checklist
Delete any items that are not applicable to this PR.
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
### For maintainers
- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
This commit is contained in:
parent
befa48828c
commit
af6fb117b5
1 changed files with 19 additions and 9 deletions
|
@ -54,6 +54,24 @@ export const SearchBox: FunctionComponent<Props> = ({
|
|||
});
|
||||
};
|
||||
|
||||
const onCategoryButtonClick = () => {
|
||||
if (selectedSubCategory) {
|
||||
if (setSelectedSubCategory) setSelectedSubCategory(undefined);
|
||||
setUrlandReplaceHistory({
|
||||
categoryId: selectedCategory,
|
||||
subCategoryId: '',
|
||||
});
|
||||
} else {
|
||||
setCategory('');
|
||||
if (setSelectedSubCategory) setSelectedSubCategory(undefined);
|
||||
setUrlandReplaceHistory({
|
||||
searchString: '',
|
||||
categoryId: '',
|
||||
subCategoryId: '',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const selectedCategoryTitle = selectedCategory
|
||||
? categories.find((category) => category.id === selectedCategory)?.title
|
||||
: undefined;
|
||||
|
@ -100,15 +118,7 @@ export const SearchBox: FunctionComponent<Props> = ({
|
|||
{getCategoriesLabel}
|
||||
<button
|
||||
data-test-subj="epmList.categoryBadge.closeBtn"
|
||||
onClick={() => {
|
||||
setCategory('');
|
||||
if (setSelectedSubCategory) setSelectedSubCategory(undefined);
|
||||
setUrlandReplaceHistory({
|
||||
searchString: '',
|
||||
categoryId: '',
|
||||
subCategoryId: '',
|
||||
});
|
||||
}}
|
||||
onClick={onCategoryButtonClick}
|
||||
aria-label="Remove filter"
|
||||
style={{
|
||||
padding: euiTheme.size.xs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue