Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made a new KRadioButtonGroup component to fix Firefox radio button movement with arrow keys issue #650

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fbdf0c0
Merge pull request #457 from learningequality/release-v1.5.x
MisRob Sep 28, 2023
2b44dbf
Merge remote-tracking branch 'upstream/develop' into develop
muditchoudhary Mar 29, 2024
7a2c1ad
Merge remote-tracking branch 'upstream/develop' into develop
muditchoudhary Jun 1, 2024
dd6a483
Add new KRadioButtonGroup Component
muditchoudhary Jun 3, 2024
ea5a9f1
Add setTabIndex method to set tab index on each radio component
muditchoudhary Jun 3, 2024
6100a15
Add test for KRadioButtonGroup component
muditchoudhary Jun 4, 2024
eb9c801
Add docs for KRadioButtonGroup
muditchoudhary Jun 4, 2024
fddf31e
Update tableOfContents
muditchoudhary Jun 4, 2024
afcd18f
Merge remote-tracking branch 'upstream/develop' into develop
muditchoudhary Jun 19, 2024
4b0688a
Add new KRadioButtonGroup Component
muditchoudhary Jun 3, 2024
87a3928
Add setTabIndex method to set tab index on each radio component
muditchoudhary Jun 3, 2024
ebaf9cb
Add test for KRadioButtonGroup component
muditchoudhary Jun 4, 2024
a8c1951
Add docs for KRadioButtonGroup
muditchoudhary Jun 4, 2024
3f2d8ea
Update tableOfContents
muditchoudhary Jun 4, 2024
b1d09dc
Fix: fix tab issue for change language model
muditchoudhary Jun 19, 2024
220eacf
Merge remote-tracking branch 'origin/KRadioButtonGroup-Component' int…
muditchoudhary Jun 19, 2024
29f339a
Update KRadioButtonGroup component
muditchoudhary Jun 20, 2024
73e8e76
fix lint
muditchoudhary Jul 10, 2024
df58010
Change keydown event with keyup event
muditchoudhary Jul 10, 2024
0e9be90
fix lint
muditchoudhary Jul 10, 2024
adb42c0
Fix some logics in KRadioButtonGroup, fix tests
muditchoudhary Aug 7, 2024
60d0b3d
Merge branch 'develop' into KRadioButtonGroup-Component
muditchoudhary Aug 8, 2024
3004607
Fix queryAndAddRadioBtns recursive logic and rename methods name
muditchoudhary Aug 17, 2024
c3e9712
Merge remote-tracking branch 'origin/KRadioButtonGroup-Component' int…
muditchoudhary Aug 17, 2024
b1b1816
Merge branch 'develop' into KRadioButtonGroup-Component
MisRob Aug 21, 2024
1fa0a0b
Update CHANGELOG.md
MisRob Aug 21, 2024
46566e4
Update documentation
MisRob Aug 21, 2024
fb4c3cf
Merge branch 'develop' into KRadioButtonGroup-Component
MisRob Aug 21, 2024
37272a8
Update documentation
MisRob Aug 21, 2024
bdea254
Add another example to docs
MisRob Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Changelog is rather internal in nature. See release notes for the public overvie

## Upcoming version 5.x.x (`develop` branch)

- [#650]
- **Description:** Add `KRadioButtonGroup` component to fix keyboard navigation in radio button groups in Firefox
- **Products impact:** New API
- **Addresses:** https://github.com/learningequality/kolibri/issues/10491
- **Components:** `KRadioButtonGroup`
- **Breaking:** no
- **Impacts a11y:** yes
- **Guidance:** Make sure that all `KRadioButton`s are wrapped in `KRadioButtonGroup`

[#650]: https://github.com/learningequality/kolibri-design-system/pull/650


- [#723]
- **Description:** Updates $core-time value from 0.25s to 0.15s
- **Products impact:** User experience - faster transitions
Expand Down
169 changes: 141 additions & 28 deletions docs/pages/kradiobutton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,143 @@

<DocsPageTemplate apiDocs>
<DocsPageSection title="Overview" anchor="#overview">
<p>
This is a radio button component:
</p>
<p>A radio button is used to make a single selection from a group of options. Radio buttons should be used instead of checkboxes if only one option can be selected.</p>

<p><code>KRadioButton</code>'s are always be wrapped in <DocsLibraryLink component="KRadioButtonGroup" />.</p>
</DocsPageSection>

<DocsPageSection title="Usage" anchor="#usage">
<DocsShow>
<KRadioButton
v-model="exampleValue"
label="Option A"
value="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
value="val-b"
/>
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
<KRadioButtonGroup>
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
buttonValue="val-b"
/>
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KRadioButtonGroup>
<p>
Current value: {{ exampleValue }}
</p>
</DocsShow>
<p>
A radio button is used to make a single selection from a group of options. Radio buttons should be used instead of checkboxes if only one option can be selected.
</p>

<DocsShowCode language="html">
<KRadioButtonGroup>
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
butonValue="val-b"
/>
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KRadioButtonGroup>
</DocsShowCode>

<h3>With grid layout</h3>

<p>It is possible to use radio buttons together with grid layout components such as <DocsLibraryLink component="KGrid" /> or <DocsLibraryLink component="KFixedGrid" />. For example: </p>

<DocsShow>

<KRadioButtonGroup>
<KFixedGrid :numCols="2">
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
buttonValue="val-b"
/>
</KFixedGridItem>
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KFixedGridItem>
</KFixedGrid>
</KRadioButtonGroup>

<p>
Current value: {{ exampleValue }}
</p>
</DocsShow>

<DocsShowCode language="html">
<KRadioButtonGroup>
<KFixedGrid :numCols="2">
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option A"
buttonValue="val-a"
/>
<KRadioButton
v-model="exampleValue"
label="Option B"
buttonValue="val-b"
/>
</KFixedGridItem>
<KFixedGridItem :span="1">
<KRadioButton
v-model="exampleValue"
label="Option C"
description="This one is special!"
buttonValue="val-c"
/>
<KRadioButton
v-model="exampleValue"
label="Truncated label. Adjusting your browser window size to see this in action."
buttonValue="val-d"
truncateLabel
/>
</KFixedGridItem>
</KFixedGrid>
</KRadioButtonGroup>
</DocsShowCode>
</DocsPageSection>

<DocsPageSection title="Layout" anchor="#layout">
Expand All @@ -56,11 +160,20 @@

<DocsPageSection title="Guidelines" anchor="#guidelines">
<ul>
<li>Always wrap <code>KRadioButton</code> group in <DocsLibraryLink component="KRadioButtonGroup" /></li>
<li>There must always be exactly one radio button selected within a group</li>
<li>If the user is allowed to not select any of the options, provide a "None" option</li>
<li>By default, the first radio option is selected, but may be configured to have any option preselected</li>
</ul>
</DocsPageSection>

<DocsPageSection title="Related" anchor="#related">
<ul>
<li>
<DocsLibraryLink component="KRadioButtonGroup" /> ensures <code>KRadioButton</code> groups are accessible in all supported browsers.
</li>
</ul>
</DocsPageSection>
</DocsPageTemplate>

</template>
Expand Down
13 changes: 13 additions & 0 deletions docs/pages/kradiobuttongroup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>

<DocsPageTemplate :apiDocs="true">

<DocsPageSection title="Overview" anchor="#overview">
<p>
Ensures <code>KRadioButton</code> groups are accessible in all supported browsers. Refer to <DocsLibraryLink component="KRadioButton" /> for more.
</p>
</DocsPageSection>

</DocsPageTemplate>

</template>
5 changes: 5 additions & 0 deletions docs/tableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ export default [
title: 'KListWithOverflow',
isCode: true,
}),
new Page({
path: '/kradiobuttongroup',
title: 'KRadioButtonGroup',
isCode: true,
}),
new Page({
path: '/kcard',
title: 'KCard',
Expand Down
19 changes: 18 additions & 1 deletion lib/KRadioButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ref="input"
v-autofocus="autofocus"
type="radio"
:tabindex="tabIndex"
class="k-radio-button-input"
:checked="isChecked"
:value="buttonValue !== null ? buttonValue : value"
Expand Down Expand Up @@ -71,7 +72,9 @@
};

/**
* Used to display all options
* Used to display radio buttons.
*
* To be used within `KRadioButtonGroup`.
*/
export default {
name: 'KRadioButton',
Expand Down Expand Up @@ -148,6 +151,7 @@
},
data: () => ({
active: false,
tabIndex: 0,
}),
computed: {
isChecked() {
Expand Down Expand Up @@ -183,6 +187,12 @@
}
},
methods: {
/**
* Toggles the check state of the radio button.
*
* @public
* @param {Event} event - The event object.
*/
toggleCheck(event) {
if (!this.disabled) {
this.focus();
Expand Down Expand Up @@ -220,6 +230,13 @@
*/
this.$emit('blur');
},
/**
* @public
* Sets `tab-index` on input
*/
setTabIndex(val) {
this.tabIndex = val;
},
},
};

Expand Down
Loading