Skip to content

Commit d05c619

Browse files
authored
fix(checkbox): disallow keynav on readonly radios
A readyonly radio checkbox should not change its state via keynav from another radio of the same group. This PR covers the situation when the readonly radio is already unchecked. When it is already checked, it doesn't make sense to set this as the_only_ option to readonly as a radio is part of a radio group which, by nature, only has 1 active selection. And if one does not want this already selected option to be changed, all the other options from the same radio group should be either set to readonly or disabled.
1 parent a47840f commit d05c619

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/definitions/modules/checkbox.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
;
211211

212212
var
213-
r = module.get.radios(),
213+
r = module.get.radios().not(selector.disabled),
214214
rIndex = r.index($module),
215215
rLen = r.length,
216216
checkIndex = false
@@ -228,7 +228,10 @@
228228

229229
return false;
230230
}
231-
if (settings.beforeChecked.apply($(r[checkIndex]).children(selector.input)[0]) === false) {
231+
var nextOption = $(r[checkIndex]),
232+
nextInput = nextOption.children(selector.input),
233+
disallowOption = nextOption.hasClass(className.readOnly) || nextInput.prop('readonly');
234+
if (disallowOption || settings.beforeChecked.apply(nextInput[0]) === false) {
232235
module.verbose('Next option should not allow check, cancelling key navigation');
233236

234237
return false;
@@ -875,6 +878,7 @@
875878

876879
selector: {
877880
checkbox: '.ui.checkbox',
881+
disabled: '.disabled, :has(input[disabled])',
878882
label: 'label',
879883
input: 'input[type="checkbox"], input[type="radio"]',
880884
link: 'a[href]',

0 commit comments

Comments
 (0)