fix(features): open feature permalinks for features beyond the first …#7839
fix(features): open feature permalinks for features beyond the first …#7839narendraio wants to merge 1 commit into
Conversation
…page A feature permalink (`?feature=<id>`) is opened by the matching `FeatureRow`'s own effect, but rows are only rendered for the current page of results. When the linked feature lives on a later page no row exists, so the permalink was a no-op and the user simply landed on the first page. Add a `FeaturePermalinkHandler` that, when the linked feature is not present on the current page, fetches the feature and its environment feature state and renders a single hidden `FeatureRow`, reusing the existing panel-opening logic rather than duplicating it. Closes Flagsmith#4239
|
@narendraio is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
This comment was marked as spam.
This comment was marked as spam.
Zaimwa9
left a comment
There was a problem hiding this comment.
Thanks for the contribution. I had a first pass over the code, Vercel is unavailable. As soon as it is back I will smoke test for a final review (post changes) 👍
| id: featureId, | ||
| project: projectId, | ||
| }) | ||
| const { data: featureStates } = useGetFeatureStatesQuery({ |
There was a problem hiding this comment.
We should also use isLoading from this hook to early return if the projectFlag was returned faster than the environment flags states, otherwise the modal might open end up in a stale state where it is complicated to re-open
|
|
||
| const environmentFlags = useMemo(() => { | ||
| const environmentFeatureState = featureStates?.results?.find( | ||
| (featureState) => !featureState.feature_segment && !featureState.identity, |
There was a problem hiding this comment.
| (featureState) => !featureState.feature_segment && !featureState.identity, | |
| (featureState) => | |
| !featureState.live_from && | |
| !featureState.feature_segment && | |
| !featureState.identity, |
We need to also filter out scheduled feature state changes
| : {} | ||
| }, [featureStates, featureId]) | ||
|
|
||
| if (!projectFlag) { |
There was a problem hiding this comment.
Related to the above: if (!projectFlag || isLoading || !environmentFeatureState) {
Description (replace the blank template with this):
docs/if required so people know about the feature.Changes
Closes #4239
A feature permalink (
?feature=<id>) is opened by the matchingFeatureRow'sown effect, but rows are only rendered for the current page of results. When the
linked feature lives on a later page no row exists, so the permalink was a no-op
and the user simply landed on the first page.
This adds a
FeaturePermalinkHandlerthat, when the linked feature is notpresent on the current page, fetches the feature and its environment feature
state and renders a single hidden
FeatureRow— reusing the existingpanel-opening logic rather than duplicating it.
How did you test this code?
Manually:
/project/<id>/environment/<key>/features?feature=<id>&tab=value.landing on the first page with nothing open.
Also ran
npm run typecheckandeslinton the changed files (no new errors).