From bf5e9940487372857ce6e893008d482c60b4a2c1 Mon Sep 17 00:00:00 2001 From: Ian Maffett Date: Mon, 13 Oct 2014 09:30:02 -0400 Subject: [PATCH 1/2] Component: Select Custom Fixes case where non-native multiple select is used and checkbox is not un-checked when setting .prop(" selected ", false) Closes gh-7732 --- js/widgets/forms/select.custom.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/widgets/forms/select.custom.js b/js/widgets/forms/select.custom.js index 38c46074bee..8b6b78b8111 100644 --- a/js/widgets/forms/select.custom.js +++ b/js/widgets/forms/select.custom.js @@ -330,10 +330,8 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, { .find( "a" ).removeClass( $.mobile.activeBtnClass ).end() .attr( "aria-selected", false ) .each(function( i ) { - + var item = $( this ); if ( $.inArray( i, indices ) > -1 ) { - var item = $( this ); - // Aria selected attr item.attr( "aria-selected", true ); @@ -348,6 +346,9 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, { } } } + else if ( self.isMultiple ) { + item.find( "a" ).removeClass( "ui-checkbox-off" ).addClass( "ui-checkbox-on" ); + } }); }, From f660f80d0391c1a99d61918df3cf970c6d6fc9ac Mon Sep 17 00:00:00 2001 From: Ian Maffett Date: Tue, 14 Oct 2014 08:01:54 -0400 Subject: [PATCH 2/2] Component: Select Custom Real fix (before I was adding the class instead of removing) Add test case in tests/unit/select/select_core.js --- js/widgets/forms/select.custom.js | 2 +- tests/unit/select/select_core.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/js/widgets/forms/select.custom.js b/js/widgets/forms/select.custom.js index 8b6b78b8111..00ddd96bd71 100644 --- a/js/widgets/forms/select.custom.js +++ b/js/widgets/forms/select.custom.js @@ -347,7 +347,7 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, { } } else if ( self.isMultiple ) { - item.find( "a" ).removeClass( "ui-checkbox-off" ).addClass( "ui-checkbox-on" ); + item.find( "a" ).removeClass( "ui-checkbox-on" ).addClass( "ui-checkbox-off" ); } }); }, diff --git a/tests/unit/select/select_core.js b/tests/unit/select/select_core.js index 7a0b2306773..43a62dc583e 100644 --- a/tests/unit/select/select_core.js +++ b/tests/unit/select/select_core.js @@ -12,6 +12,20 @@ deepEqual( $( "#enhance-test-listbox a:first" ).attr( "role" ), "button", "The close button for a multiple choice select popup has the " + '"' + "role='button'" + '"' + " set" ); deepEqual( popup.popup( "option", "overlayTheme" ), "b", "Popup has overlayTheme b" ); deepEqual( popup.popup( "option", "theme" ), "x", "Popup has theme x" ); + + }); + + module( "Custom select Multiple" ); + + test( "Custom select multiple is cleared correctly", function() { + var popup = $( "#enhance-test-listbox" ); + $("#enhance-test") + .find("option") + .attr("selected", false) + .prop("selected", false) + .end() + .selectmenu("refresh"); + deepEqual(popup.find(".ui-checkbox-on").length,0,"Checkboxes should not have ui-checkbox-on class"); }); module( "Native select" );