Skip to content

Allow dropdown inputs to be manually enabled for DnD questions for accessibility - #2159

Open
sjd210 wants to merge 53 commits into
mainfrom
feature/non-dragging-input-setting
Open

Allow dropdown inputs to be manually enabled for DnD questions for accessibility #2159
sjd210 wants to merge 53 commits into
mainfrom
feature/non-dragging-input-setting

Conversation

@sjd210

@sjd210 sjd210 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Adds an accessibility setting to "Enable non-dragging alternative inputs". For now this only affects cloze/drag-and-drop questions, but is defined broadly enough that we can use the same setting for other inputs in the future if they apply (e.g. depending on how we implement reorder question accessibility).

Also adds a Dropdown/Drag and drop override toggle to all question and quiz pages containing these input types in the top right, equivalent to the context switcher on concept pages. The toggle is defaulted to Dropdown if the user has enabled the accessibility setting or is on a mobile device, and Drag and drop otherwise. If manually toggled, this overrides all other settings and the toggled input mode is enabled instead (e.g. allowing drag and drop at xs screens, if wanted).

I'm not 100% confident on things like:

  • if we should hide the toggle for logged-in users with the new setting disabled (so they'd see no external change)
  • the exact placement of these toggles - there could be an option to hide it? or we could add it to the sidebar instead? 🤷‍♀️

Thoughts welcome!

Also requires https://github.com/isaacphysics/isaac-sops-config/pull/22 for new accessibility setting to work. Merged!


Known problem: If a question is using dropdowns on first page load, then the first time drag and drop is switched to the dropzones will not load properly. This is a pre-existing issue (try some incremental page width changes on a live question) but is surfaced a lot more heavily here. This is sure to be some portalling shenanigans, and I don't think we should merge this without fixing it, but the rest is ready to review now.

@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.23881% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.56%. Comparing base (607cd20) to head (dbc7ca3).
⚠️ Report is 99 commits behind head on main.

Files with missing lines Patch % Lines
src/app/services/accessibility.ts 41.17% 10 Missing ⚠️
...lements/alerts/InaccessibleContentWarningAlert.tsx 41.66% 7 Missing ⚠️
src/app/components/content/IsaacClozeQuestion.tsx 0.00% 3 Missing ⚠️
...pp/components/content/IsaacDragAndDropQuestion.tsx 0.00% 3 Missing ⚠️
src/app/state/selectors.tsx 0.00% 3 Missing ⚠️
...onents/elements/markup/portals/InlineDropZones.tsx 0.00% 2 Missing ⚠️
...ents/elements/panels/UserAccessibilitySettings.tsx 33.33% 2 Missing ⚠️
src/app/state/reducers/userState.ts 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2159      +/-   ##
==========================================
+ Coverage   43.20%   43.56%   +0.35%     
==========================================
  Files         601      602       +1     
  Lines       25728    25796      +68     
  Branches     8566     8594      +28     
==========================================
+ Hits        11116    11238     +122     
+ Misses      14555    14501      -54     
  Partials       57       57              

☔ View full report in Codecov by Harness.
📢 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.

Comment thread src/app/components/content/IsaacClozeQuestion.tsx Fixed
Comment thread src/app/components/elements/PageMetadata.tsx Fixed
Comment thread src/app/components/elements/PageMetadata.tsx Fixed
@sjd210
sjd210 marked this pull request as ready for review May 21, 2026 09:34
Comment thread src/app/components/elements/sidebar/QuizSidebar.tsx Fixed
Comment thread src/app/components/elements/sidebar/QuizSidebar.tsx Fixed

@jacbn jacbn left a comment

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 looking really good! I have one comment here about keeping hooks inside /services but beyond that my only consideration here is where and how we display the toggle.

As we've discussed, perhaps the most important thing for accessibility across the site is that we are consistent in how we surface accessibility features, so that using a new question type does not feel completely alien to e.g. a screenreader user.

Having a toggle at the top (which may be skipped if the user jumps to a specific section via a hash anchor) for just this question type does feel a little specific, though I can see it having value, particularly for tablets. To this end, I'm very happy for this feature to exist in the accessibility settings (and as you mention, it can remain on the page for non-logged in users), but if our plans for accessibility on other question types do not include such a toggle, I think I'd prefer we improve the accessibility on Cloze by allowing click-to-select and click-to-drop, so that we remain consistent in that all questions can be answered accessibly without requiring a toggle elsewhere on the page.

I'd love to be able to ask an accessibility panel about how they feel about which method is most accessible, as I can only base this off being consistent with other questions... :/

Comment thread src/app/components/content/IsaacDragAndDropQuestion.tsx Outdated
@sjd210

sjd210 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

The main changes since last review:

  • Move DnD accessibility hook inside /services
  • Move "dropdown/drag and drop" toggle inside InaccessibleContentWarningAlert, and colour it to match
    • This allows the flexibility of users being able to both control the default mode and whether they see the toggle separately
    • (I don't think I agree that this is the best choice, but I think this is an acceptable one and that we're not going to come to an easy agreement otherwise)
  • Fix portalling issue (🤞) on switching between input modes by putting the main setPortalFuncs() inside a useEffect, giving it the potential to update on every render based on the contents of newPortalFuncs.
  • Enable accessibility tags for quizzes
    • (Note: The ViewQuizzes page uses ALVIs but the MyQuizzes page doesn't. The tags will only show externally on ViewQuizzes - perhaps we should amend this)

See commit messages for other small things.

@jacbn jacbn left a comment

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.

I think this still needs some further refinement – I've listed a few points below. For the last one, as we both disagree with content's decision(s) on how the toggle should work / where it should be, maybe we need to better convince them otherwise? :/

Comment on lines +15 to +20
<StyledToggle
checked={dragAndDropEnabled}
falseLabel="Dropdown"
trueLabel="Drag and drop"
onChange={(e) => {toggleDragAndDropEnabled(); e.stopPropagation();}}
/>

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.

We ought to consider improving the styling for this in dark mode – both are accessibility features and having both on is currently extremely illegible!

1: Input mode toggle
Image

2: Drop zone button replacement
Image

@sjd210 sjd210 Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For 1, we have an (incomplete) spectrum of misc orange colours that I had already been thinking of adding this to - but it isn't inverted as part of the dark theme. The colours are barely used, but for future cases like this where they would be used we probably should incorporate them into the colour shifting so we don't get problems like this. I'll work on that.

For 2, giving them backgrounds at all was intended to fix an issue with the dropdown items overlapping with images. Of course this does still work with a darker background rather than white, but it no longer blends into the background of most images. This is probably fine, but just to note.

image image

if (!isEqual(portalFuncs, newPortalFuncs)) {
setPortalFuncs(newPortalFuncs);
}
}, [newPortalFuncs, portalFuncs]);

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 doesn't seem to have fixed the portals issue – I still get missing inputs after changing from Dropdown => DnD for the first time since page load:
Image

On Ada, it seems to keep happening until I toggle twice...

@sjd210 sjd210 Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a problem with me poorly cleaning up the messy code I had after my load of portal testing 🤦

The other half of this should be reconstructing the portalFunc callback when the toggle is used by adding dragAndDropEnabled as a dependency - which is what actually triggers the useEffect.

NOW it should hopefully be fixed...

</DropdownItem>
{dropdownItems.map((item, i) => {
return <DropdownItem key={i}
className={!nonSelectedItemIds.includes(item.id) ? "invalid" : ""}

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.

A subtle issue, but switching from DnD <=> drop zones clears the nonSelectedItemIds, meaning that items that have been used appear to be selectable again despite not doing anything when clicked. For example, in the following image, 3N should be greyed out, as it is used prior:

Image

aria-describedby="non-dragging-movement-helptext"
removeVerticalOffset
/></b>
<p id="non-dragging-helptext">{`Enabling this will allow you to use alternative input methods that don't require dragging for certain question types (e.g. drag-and-drop).`}</p>

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.

I do find this a little confusing as is.

"Enabling this will allow you to use..." makes it sound like you will be given the option to use alternative input methods for DnD questions, presumably somewhere on the question page. But if you haven't selected "Warn about inaccessible content" too then you aren't given any options, and the questions are just forcibly set to using dropdowns with no indication that anything has changed. I was expecting the toggle to exist in all situations, but accessible from within the banner if said banner exists (such that all accessibility-related content is in the same place), or outside above the (entire) question otherwise. It could even still have a warning banner in the case where "Warn about inaccessible content" is off, for consistency's sake, but I'm not sure what the text would say in that case.

Speaking of things we disagree with in your latest comment, I disagree with the solution to use an in-question toggle at all. I truly believe the chances of needing to switch an accessibility setting once you have set them initially is incredibly negligible. Why do content insist on the option there on every question?? It's messy for us having to consider situations like this and just clutters the accessibility tree... ugh.

@sjd210 sjd210 Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On the latter point, I think they see this as both an accessibility setting AND a convenience one. Like I remember them raising that for DnD questions taller than the user's screen, it would be helpful to be able to enable dropdowns for that question in particular - but that they might still want dragging for a more reasonably-sized question. That does sound more like a problem with the question content being too tall, but I can at least see where the idea is coming from.

sjd210 added 2 commits August 17, 2026 15:59
This incorporates the current partial orange palette, $color-misc-pale-yellow (as 100) and $color-wildcard-orange (as 500), and is built to correspond to the hue shifts of bootstrap's alert colours.

Most colours in the spectrum as-yet unused, but they should enable future development.
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.

4 participants