RCFilters UI: Prevent label from stealing focus on click
authorMoriel Schottlender <moriel@gmail.com>
Mon, 17 Apr 2017 21:19:31 +0000 (14:19 -0700)
committerMoriel Schottlender <moriel@gmail.com>
Mon, 17 Apr 2017 21:19:31 +0000 (14:19 -0700)
The filter options' labels are set as "label for" the checkbox
which means that by default they "give" the focus away to the
checkbox when clicked. However, we don't want that behavior so
that we can continue arrow movement through the filter option
items rather than the DOM elements. Also, the checkbox prevents
defaults on click as well as it is.

Change-Id: I9758b0dacd8cd647ec5e3e623edc66e1d7f7420a

resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterMenuOptionWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js

index b46c069..bda537f 100644 (file)
                        label: $label,
                        align: 'inline'
                } );
-
                // Event
                this.model.connect( this, { update: 'onModelUpdate' } );
                this.model.getGroupModel().connect( this, { update: 'onGroupModelUpdate' } );
+               // HACK: Prevent defaults on 'click' for the label so it
+               // doesn't steal the focus away from the input. This means
+               // we can continue arrow-movement after we click the label
+               // and is consistent with the checkbox *itself* also preventing
+               // defaults on 'click' as well.
+               layout.$label.on( 'click', false );
 
                this.$element
                        .addClass( 'mw-rcfilters-ui-filterMenuOptionWidget' )
index 2461929..c09de18 100644 (file)
         */
        mw.rcfilters.ui.FilterTagMultiselectWidget.prototype.onMenuChoose = function ( item ) {
                this.controller.toggleFilterSelect( item.model.getName() );
+
+               this.focus();
        };
 
        /**