Make KRadioButton
to show a warning for developers when it's not nested inside KRadioButtonGroup
#761
Labels
Component: KRadioButton
Component: KRadioButtonGroup
good first issue
Self-contained, straightforward, low-complexity
help wanted
Open source contributors welcome
P2 - normal
Priority: Nice to have
TAG: a11y
TAG: dev experience
🌱 Are you new to the codebase? Welcome! Please see the contributing guidelines.
Summary
In #650, we introduced a new
KRadioButtonGroup
that ensuresKRadioButton
groups are accessible in all supported browsers. For this to properly work, allKRadioButton
s need to be nested insideKRadioButtonGroup
likebut it could also be more deeply nested structures such as
The goal of this issue is to add logic to
KRadioButton
that shows a warning for developers when it's not nested insideKRadioButtonGroup
.The Value Add
This will notify developers about the proper usage and ensures expected a11y behavior for users.
Possible Tradeoffs
A risk of possible performance issues since it adds logic to every
KRadioButton
that needs to traverse all its parents (see "Guidance" on how to possibly take care of this)Guidance
KRadioButton
documentation page with more examples of usageKRadioButton
is nested inKRadioButtonGroup
so we will need to look at its chain of parents untilKRadioButtonGroup
is found.KRadioButton
, we need to be careful to not use techniques of accessing the DOM that may cause performance issues.this.$parent
and checking each$parent
's$options._componentTag
until we find'KRadioButtonGroup'
component tag or until there is no more parents, could be the wayif (process.env.NODE_ENV !== 'production') {
. @rtibbles says "this will also tree shake the code out in webpack builds." ;)Acceptance criteria
KRadioButton
sComments
This update would ideally be released after learningequality/kolibri#12596 so that we're not overwhelmed by warnings in Kolibri ;)
The text was updated successfully, but these errors were encountered: