mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 00:47:50 +01:00
fix(flags): prevent kea logic loop when switching tabs in FF UI (#26257)
This commit is contained in:
parent
d8776382b6
commit
e2f4caf218
@ -308,7 +308,8 @@ describe('Feature Flags', () => {
|
||||
cy.get('.operator-value-option').contains('> after').should('not.exist')
|
||||
})
|
||||
|
||||
it('Allow setting multivariant rollout percentage to zero', () => {
|
||||
it('Allows setting multivariant rollout percentage to zero', () => {
|
||||
cy.get('[data-attr=top-bar-name]').should('contain', 'Feature flags')
|
||||
// Start creating a multivariant flag
|
||||
cy.get('[data-attr=new-feature-flag]').click()
|
||||
cy.get('[data-attr=feature-flag-served-value-segmented-button]')
|
||||
@ -328,6 +329,15 @@ describe('Feature Flags', () => {
|
||||
cy.get('[data-attr=feature-flag-variant-rollout-percentage-input]').click().type(`4.5`).should('have.value', 4)
|
||||
})
|
||||
|
||||
it('Sets URL properly when switching between tabs', () => {
|
||||
cy.get('[data-attr=top-bar-name]').should('contain', 'Feature flags')
|
||||
cy.get('[data-attr=feature-flags-tab-navigation]').contains('History').click()
|
||||
cy.url().should('include', `tab=history`)
|
||||
|
||||
cy.get('[data-attr=feature-flags-tab-navigation]').contains('Overview').click()
|
||||
cy.url().should('include', `tab=overview`)
|
||||
})
|
||||
|
||||
it('Renders flags in FlagSelector', () => {
|
||||
// Create flag name
|
||||
cy.get('[data-attr=top-bar-name]').should('contain', 'Feature flags')
|
||||
|
@ -436,6 +436,7 @@ export function FeatureFlags(): JSX.Element {
|
||||
content: <ActivityLog scope={ActivityScope.FEATURE_FLAG} />,
|
||||
},
|
||||
]}
|
||||
data-attr="feature-flags-tab-navigation"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
@ -239,7 +239,17 @@ export const featureFlagsLogic = kea<featureFlagsLogicType>([
|
||||
pageFiltersFromUrl.page = parseInt(page)
|
||||
}
|
||||
|
||||
actions.setFeatureFlagsFilters({ ...DEFAULT_FILTERS, ...pageFiltersFromUrl })
|
||||
// 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 })
|
||||
}
|
||||
},
|
||||
})),
|
||||
events(({ actions }) => ({
|
||||
|
Loading…
Reference in New Issue
Block a user