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 2 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:** Kolibri's Setup Wizard
Copy link
Member

Choose a reason for hiding this comment

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

Could you please change this to "bugfix"? This is not as much about the place it fixes, but rather a general category. There are some examples in the PR template you can choose from.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, hadn't noticed that. Thanks!

- **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

- [#478]
- **Description:** Changed _dev-only to dev-only
- **Products impact:** -
Expand All @@ -18,7 +29,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