Skip to content

Hide "add more content" if all contexts selected#1950

Merged
jacbn merged 8 commits intomainfrom
hotfix/hide-add-stages
Feb 5, 2026
Merged

Hide "add more content" if all contexts selected#1950
jacbn merged 8 commits intomainfrom
hotfix/hide-add-stages

Conversation

@axlewin
Copy link
Copy Markdown
Contributor

@axlewin axlewin commented Jan 29, 2026

Also fixes a bug where additional contexts on Ada were initialised to All Stages/Ada despite displaying a different stage/exam board combination.

axlewin and others added 6 commits January 29, 2026 14:45
When an additional context is added, it is initialised to undefined. Isaac handles this by showing an empty box, but Ada shows a misleading stage/exam board selection when actually a useEffect is re-initialising the new context to All/Ada.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.49%. Comparing base (203fc43) to head (b92c265).
⚠️ Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
...onents/elements/inputs/UserContextAccountInput.tsx 37.50% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1950      +/-   ##
==========================================
+ Coverage   42.46%   42.49%   +0.02%     
==========================================
  Files         575      575              
  Lines       24521    24553      +32     
  Branches     8071     8135      +64     
==========================================
+ Hits        10413    10433      +20     
- Misses      13442    13454      +12     
  Partials      666      666              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

[VRT] Update baselines for hotfix/hide-add-stages
Comment on lines +145 to +146
const isAllContexts = userContexts.some(uc => uc.stage === STAGE.ALL && (isPhy || uc.examBoard === EXAM_BOARD.ALL)) ||
!getFilteredStageOptions({byUserContexts: userContexts, hideFurtherA: true}).length;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine on Sci, but the Ada picker is really quite broken (through no fault of this PR) and this component really needs some more time put into it :/


very skippable essay:

First, some context about ALL. IIRC the original intention on Sci was that you can only select STAGE.ALL if there was only one stage. This prevented you selecting overlapping combinations (e.g. ALL + GCSE).

As an aside, this is why the userContexts.length === 1 check was there before; the new .some approach doesn't rely on this assumption so is perhaps more future-proof, but right now can only ever be true on the first stage.

The inclusion of exam board breaks this assumption. ALL / AQA and ALL / SQA is a non-overlapping stage / exam board pair, but we never allowed this because we'd kept the "only allow ALL on the first stage" rule. Your fix where you also check uc.examBoard === EXAM_BOARD.ALL would fix this, but we also only allow ALL to appear in the stage dropdown if there is only one combination, so if you try to add another combination the original ALL selection is forcibly removed and you can't select it again.

This is then where the problem compounds, because while we could just stop the dropdown hiding ALL, it then becomes very difficult to prevent overlapping combinations, or at least any solution that does has a terrible UX. If you have GCSE / AQA and A Level / AQA already and then decide you want all of AQA, you have to just know to delete one of them to set the other's stage to ALL. There are a few other conceivably annoying scenarios too.


I wonder if, rather than having a super complex solution that deals with all these cases, we actually even need it. Is it likely a teacher wants ALL / AQA and ALL / SQA? To me, if they want two exam boards, they're probably teaching two classes at different age groups, so managing this with specific combinations would be fine.

My suggestion, then, is simply this:

const noMoreValidStages = !getFilteredStageOptions({byUserContexts: userContexts, hideFurtherA: true}).length;
const isAllStages = userContexts.length === 1 && userContexts[0].stage === STAGE.ALL || noMoreValidStages;

That is, we take the getFilteredStageOptions check you've added (as noMoreValidStages) and mix it in with just the ALL stage check that was there before (would be happy to use the .some approach you used too). I prefer the name isAllStages as we would just be using stages now, so the uses would need to keep the old name.

This seems to function entirely fine, i.e. you can keep adding stages and it runs until there are no more unique combinations. The only thing you can't do is multiple ALL / {exam board} pairs, but I think that's a fair tradeoff as this seems rare.

@jacbn jacbn merged commit e641902 into main Feb 5, 2026
10 checks passed
@jacbn jacbn deleted the hotfix/hide-add-stages branch February 5, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants