Add / remove spinner on pagination changes #281
Merged
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.
We recently refactored how the spinner is applied and removed when changing between tabs, but neglected to be consistent when it comes to pagination changes.
Relevant ticket:
https://mitlibraries.atlassian.net/browse/use-201
How does this address that need:
This adds the same add/remove calls for managing the spinner to the pagination management branches of the javascript file. It elects to maintain the separate pathways for these calls, rather than trying to handle the spinner in a unified area of the event listeners.
Side effects:
The duplication of calls, like lines 46-50 being basically the same as lines 26-30, may be seen as a code smell later. For now, though, I prefer to keep them separate like this - both for parity between these pathways and also symmetry with the .classList.add() lines at 61 and 75.
It seems safer to handle the spinner only in qualified contexts, rather than risking it appearing or disappearing without that being intended. I suspect that what's needed is an ARIA live region around the results, with maybe a status
Developer
Accessibility
While I've run WAVE, I'm not sure this is the right tool for a PR like this - but I don't know of another one. I've confirmed via VoiceOver that the focus moves back to the top of the results list, and that the spinner doesn't interfere with the user's ability to move through the new results.
What I'm not certain about is what the best way is to advise the user that the focus has changed. I suspect that what might be needed would be to wrap the spinner with an
aria-role="status"attribute, while also declaring the results list to be a live region - but this feels non-trivial and something I'd like to dig into specifically, rather than handle it incidentally while fixing how pagination gets the spinner or not.I'll figure out the right venue to raise this for the project team.
New ENV
Approval beyond code review
Additional context needed to review
E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing