mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 00:47:50 +01:00
fix(flags): prevent kea logic loop and clean filters on tab switch (#26258)
This commit is contained in:
parent
e2f4caf218
commit
a41bd2d4f9
@ -17,10 +17,8 @@ describe('Feature Flags', () => {
|
||||
})
|
||||
|
||||
it('Display product introduction when no feature flags exist', () => {
|
||||
// ensure unique names to avoid clashes
|
||||
cy.get('[data-attr=top-bar-name]').should('contain', 'Feature flags')
|
||||
cy.get('[data-attr=new-feature-flag]').click()
|
||||
cy.contains('Create your first feature flag').should('exist')
|
||||
cy.contains('Welcome to Feature flags!').should('exist')
|
||||
})
|
||||
|
||||
it('Create feature flag', () => {
|
||||
@ -104,6 +102,7 @@ describe('Feature Flags', () => {
|
||||
cy.get('[data-attr=feature-flag-key]').focus().type(name).should('have.value', name)
|
||||
cy.get('[data-attr=rollout-percentage]').type('{selectall}50').should('have.value', '50')
|
||||
cy.get('[data-attr=save-feature-flag]').first().click()
|
||||
cy.get('[data-attr=toast-close-button]').click()
|
||||
|
||||
// after save there should be a delete button
|
||||
cy.get('[data-attr="more-button"]').click()
|
||||
@ -336,6 +335,9 @@ describe('Feature Flags', () => {
|
||||
|
||||
cy.get('[data-attr=feature-flags-tab-navigation]').contains('Overview').click()
|
||||
cy.url().should('include', `tab=overview`)
|
||||
|
||||
cy.get('[data-attr=feature-flags-tab-navigation]').contains('History').click()
|
||||
cy.url().should('include', `tab=history`)
|
||||
})
|
||||
|
||||
it('Renders flags in FlagSelector', () => {
|
||||
|
@ -180,6 +180,10 @@ export const featureFlagsLogic = kea<featureFlagsLogicType>([
|
||||
await breakpoint(300)
|
||||
actions.loadFeatureFlags()
|
||||
},
|
||||
setActiveTab: () => {
|
||||
// Don't carry over pagination from previous tab
|
||||
actions.setFeatureFlagsFilters({ page: 1 }, true)
|
||||
},
|
||||
})),
|
||||
actionToUrl(({ values }) => {
|
||||
const changeUrl = ():
|
||||
@ -231,25 +235,10 @@ export const featureFlagsLogic = kea<featureFlagsLogicType>([
|
||||
order,
|
||||
}
|
||||
|
||||
if (active !== undefined) {
|
||||
pageFiltersFromUrl.active = String(active)
|
||||
}
|
||||
pageFiltersFromUrl.active = active !== undefined ? String(active) : undefined
|
||||
pageFiltersFromUrl.page = page !== undefined ? parseInt(page) : undefined
|
||||
|
||||
if (page !== undefined) {
|
||||
pageFiltersFromUrl.page = parseInt(page)
|
||||
}
|
||||
|
||||
// Initialize filters with the URL params if none are set
|
||||
const isInitializingFilters =
|
||||
objectsEqual(DEFAULT_FILTERS, values.filters) && !objectsEqual(DEFAULT_FILTERS, pageFiltersFromUrl)
|
||||
/**
|
||||
* Pagination search param in the URL is modified directly by the LemonTable component,
|
||||
* so let's update filter state if it changes
|
||||
*/
|
||||
const isChangingPage = page !== undefined && page !== values.filters.page
|
||||
if (isInitializingFilters || isChangingPage) {
|
||||
actions.setFeatureFlagsFilters({ ...DEFAULT_FILTERS, ...pageFiltersFromUrl })
|
||||
}
|
||||
actions.setFeatureFlagsFilters({ ...DEFAULT_FILTERS, ...pageFiltersFromUrl })
|
||||
},
|
||||
})),
|
||||
events(({ actions }) => ({
|
||||
|
Loading…
Reference in New Issue
Block a user