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

Fix KRadioButton autofocus on dynamic rendering #492

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ Changelog is rather internal in nature. See release notes for the public overvie

## Version 2.0.0

- [#492]
- **Description:** Add autofocus directive on KRadioButton to fix autofocus behavior on dynamic rendering.
- **Products impact:** bugfix
- **Addresses:** https://github.com/learningequality/kolibri-design-system/issues/489
- **Components:** KRadioButton
- **Breaking:** no
- **Impacts a11y:** yes
- **Guidance:** Add "autofocus" prop on KRadioButton. This change improves keyboard navigation on forms where a KRadioButton jumps into the DOM.
Copy link
Member

Choose a reason for hiding this comment

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

Nice, thanks!


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

- [#497]
- **Description:** KDropdownMenu now emits a @tab event when the user hits the [Tab] key and a @close event when the menu is closed programmatically. Additionally, a new icon for Expand All was added and can be used just like any other icon with the "expandAll" name.
- **Products impact:** updated API
Expand Down Expand Up @@ -40,7 +51,7 @@ Changelog is rather internal in nature. See release notes for the public overvie

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

- [#482]
- [#482]
- **Description:** Changed develop branch to main branch in Readme
- **Products impact:** -
- **Addresses:** https://github.com/learningequality/kolibri-design-system/issues/479
Expand Down
13 changes: 12 additions & 1 deletion lib/KRadioButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<input
:id="id"
ref="input"
v-autofocus="autofocus"
type="radio"
class="k-radio-button-input"
:checked="isChecked"
:value="value"
:disabled="disabled"
:autofocus="autofocus"
@click.stop="toggleCheck"
@focus="active = true"
@blur="blur"
Expand Down Expand Up @@ -70,11 +70,22 @@

<script>

const autofocus = {
inserted(el, { value }) {
if (value) {
el.focus();
}
},
};

/**
* Used to display all options
*/
export default {
name: 'KRadioButton',
directives: {
autofocus,
},
model: {
prop: 'currentValue',
},
Expand Down
Loading