Skip to content

Commit

Permalink
clear the taxonomic filter search when the column configurator is saved
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Mar 4, 2022
1 parent bf26aea commit 21500ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AppContext } from '~/types'
import { taxonomicFilterLogic } from 'lib/components/TaxonomicFilter/taxonomicFilterLogic'
import { groupsModel } from '~/models/groupsModel'
import { actionsModel } from '~/models/actionsModel'
import { columnConfiguratorLogic } from 'lib/components/ResizableTable/columnConfiguratorLogic'

jest.mock('lib/api')

Expand All @@ -39,6 +40,7 @@ describe('taxonomicFilterLogic', () => {
teamLogic.mount()
actionsModel.mount()
groupsModel.mount()
columnConfiguratorLogic({ selectedColumns: [] }).mount()
})

const setupLogic = (clearSearchOnSelection?: boolean): void => {
Expand Down Expand Up @@ -73,6 +75,15 @@ describe('taxonomicFilterLogic', () => {
searchQuery: 'tomato',
})
})

it('clears the search query when the column configurator saves', async () => {
await expectLogic(logic, () => {
logic.actions.setSearchQuery('tomato')
columnConfiguratorLogic.actions.save()
}).toMatchValues({
searchQuery: '',
})
})
})

describe('with the default of clearing search query on selection', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { FEATURE_FLAGS } from 'lib/constants'
import { ActionStack, CohortIcon, PropertyIcon } from 'lib/components/icons'
import { keyMapping } from 'lib/components/PropertyKeyInfo'
import { getEventDefinitionIcon, getPropertyDefinitionIcon } from 'scenes/data-management/events/DefinitionHeader'
import { columnConfiguratorLogic } from 'lib/components/ResizableTable/columnConfiguratorLogic'

const eventTaxonomicGroupProps = {
getPopupHeader: (eventDefinition: EventDefinition): string => {
Expand All @@ -49,6 +50,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>({
groupPropertiesModel,
['allGroupProperties'],
],
actions: [columnConfiguratorLogic, ['save']],
},
actions: () => ({
moveUp: true,
Expand Down Expand Up @@ -360,6 +362,10 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>({
],
},
listeners: ({ actions, values, props }) => ({
save: () => {
// implemented as a listener not on reducer so that the change is reflected in the infinite list data
actions.setSearchQuery('')
},
selectItem: ({ group, value, item }) => {
if (item && value) {
props.onChange?.(group, value, item)
Expand Down

0 comments on commit 21500ad

Please sign in to comment.