-
Notifications
You must be signed in to change notification settings - Fork 256
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Sub-issue of #5060.
Complexity: High
Summary
While tracked in Studio repository as part of KDS migration, this issue includes work in all Kolibri, Studio, and KDS.
In KDS, we have a private UiSnackbar component that we use for Kolibri's CoreSnackbar and GlobalSnackbar. In Studio, we have another GlobalSnackbar, but built around Vuetify's VSnackbar that we need to migrate away from.
The goal of this issue is to unify all our snackbar logic in KDS KSnackbar component + useKSnackbar composable and then use them in both Kolibri and Studio instead of the aforementioned components.
KDS
- Copy
UiSnackbarand rename it toKSnackbar(it's important to preserve the originalUiSnackbarto prevent from breaking change in Kolibri) - Remove unused Keen logic and naming (
ui-) fromKSnackbar, if any - Add features to support everything that both Kolibri's
CoreSnackbar+GlobalSnackbarand Studio'sGlobalSnackbarsupport - Make
KSnackbarto utilizeuseKLiveRegionso that in Kolibri, we can cleanup usages like
<div aria-live="polite">
<GlobalSnackbar />
</div>
(improves a11y by resolving some parts of learningequality/kolibri#12326)
- Ensure a11y features (e.g. focus / blur in Kolibri) to not get lost
- Also move Kolibri's
useSnackbarto KDS asuseKSnackbar. If Studio has any additional features related to showing/hiding snackbar and its format, add them too. - Add unit tests for
useKSnackbarand core logic ofKSnackbar. Do not use obsolete@vue/test-utilsapproach. Instead, use@testing-library/vue(Vue Testing Library). - Add visual tests for
KSnackbar - Add documentation pages for
KSnackbaranduseKSnackbar
Studio
- Replace
GlobalSnackbarandvuex/snackbarby KDSKSnackbaranduseKSnackbar - Ensure no regressions in user experience
Kolibri
- Replace
CoreSnackbar+GlobalSnackbaranduseSnackbarby KDSKSnackbaranduseKSnackbar - Cleanup unnecessary live regions related to global snackbars
- Ensure no regressions in user experience
Guidance
Some useful context from @AlexVelezLl for focus / blur (implemented in Kolibri):
I tried to implement the "return focus" action as focusing the last active element before the snackbar was shown just as we do in other places, but this didn't work well with snackbars because these snackbars many times are shown when the operation is complete, but if this operation comes from a modal (kmodal or side panel modal), then the focus is lost, because the last focused element is already unmounted when the snackbar is closed. That's why I treated it as an "onBlur" handler that was called either after the user press the tab key, or when the snackbar disappeared because of the timeout.
User experience should be preserved, but the implementation can be likely simplified during this refactor, as per Alex's:
I had to do it with directives just to avoid updating many parts of the UISnackbar that I suspected was going to be migrated at some point. But in theory I think this could be achieved using regular Vue props/event handlers.
