Fixes keyboard support on checkboxes

The keydown/keyup/input events were not working correctly. Also the $cb selector was not specific enough and was picking up on the hidden input used to define the default state.
This commit is contained in:
Samuel Georges 2019-09-14 16:11:16 +10:00
parent 5f0da7e6f6
commit 8471c73054
2 changed files with 3 additions and 10 deletions

View File

@ -5,14 +5,9 @@
(function($) {
$(document).on('keydown', 'div.custom-checkbox', function(e) {
if (e.key === '(Space character)' || e.key === 'Spacebar' || e.key === ' ')
e.preventDefault()
})
$(document).on('input', 'div.custom-checkbox', function(e) {
$(document).on('keypress', 'div.custom-checkbox', function(e) {
if (e.key === '(Space character)' || e.key === 'Spacebar' || e.key === ' ') {
var $cb = $('input', this)
var $cb = $('input[type=checkbox]', this)
if ($cb.data('oc-space-timestamp') == e.timeStamp)
return

View File

@ -2800,9 +2800,7 @@ $(document).on('focus.autocomplete.data-api','[data-control="autocomplete"]',fun
if($this.data('autocomplete'))return
var opts=$this.data()
if(opts.source){opts.source=paramToObj('data-source',opts.source)}
$this.autocomplete(opts)})}(window.jQuery);(function($){$(document).on('keydown','div.custom-checkbox',function(e){if(e.key==='(Space character)'||e.key==='Spacebar'||e.key===' ')
e.preventDefault()})
$(document).on('input','div.custom-checkbox',function(e){if(e.key==='(Space character)'||e.key==='Spacebar'||e.key===' '){var $cb=$('input',this)
$this.autocomplete(opts)})}(window.jQuery);(function($){$(document).on('keypress','div.custom-checkbox',function(e){if(e.key==='(Space character)'||e.key==='Spacebar'||e.key===' '){var $cb=$('input[type=checkbox]',this)
if($cb.data('oc-space-timestamp')==e.timeStamp)
return
$cb.get(0).checked=!$cb.get(0).checked