Fix ContentScopeControls groupBy fallback for scopes with different shapes - #6263
Draft
VPS-thodax wants to merge 1 commit into
Draft
Fix ContentScopeControls groupBy fallback for scopes with different shapes#6263VPS-thodax wants to merge 1 commit into
ContentScopeControls groupBy fallback for scopes with different shapes#6263VPS-thodax wants to merge 1 commit into
Conversation
…different shapes
The groupBy fallback derived a default dimension from the currently
selected scope's keys, but that shape isn't representative of all
available scopes. When scopes have different shapes (e.g. {domain}
vs {company}), this could apply a groupBy that other scopes don't
have, breaking the scope switcher. The fallback now only picks a
dimension when every scope shares the exact same shape. Also require
every option to have multiple dimensions before grouping is applied
in ContentScopeSelect, since mixed-shape options aren't safe to group
by a single dimension.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ContentScopeControlsderives itsgroupByfallback from the currently selected scope's own keys (Object.keys(scope)[0]). When the available scopes have different shapes (e.g.{ domain: "main" }and{ company: "123" }), this can pick a dimension that not every scope has, breaking the scope switcher on scope change.Cause
The fallback only looks at the single currently-active scope, not at the full set of available scopes (
values), so it has no way to know whether the picked dimension is actually safe to group by across all of them.Fix
The fallback now inspects all available scopes and only picks a
groupBydimension when every scope shares the exact same set of dimensions; otherwise no default is applied and the list stays ungrouped.ContentScopeSelect'shasMultipleDimensionscheck is also tightened to require every option to have more than one dimension before grouping is attempted, so a mix of shapes is never grouped by a dimension some option lacks.Verification
Added unit tests in
Controls.test.tsxcovering both cases:Further information