@@ -945,6 +945,15 @@ describe('Select', function() {
945945 } ) ;
946946 expect ( options [ 1 ] , 'to have text' , 'Three' ) ;
947947 } ) ;
948+
949+ it ( 'is does not close menu when disabled option is clicked' , function ( ) {
950+
951+ clickArrowToOpen ( ) ;
952+ TestUtils . Simulate . mouseDown ( React . findDOMNode ( instance ) . querySelectorAll ( '.Select-option' ) [ 1 ] ) ;
953+
954+ var options = React . findDOMNode ( instance ) . querySelectorAll ( '.Select-option' ) ;
955+ expect ( options . length , 'to equal' , 3 ) ;
956+ } ) ;
948957 } ) ;
949958
950959 describe ( 'with styled options' , function ( ) {
@@ -2460,6 +2469,82 @@ describe('Select', function() {
24602469 } ) ;
24612470 } ) ;
24622471
2472+ describe ( 'optionRendererDisabled' , function ( ) {
2473+
2474+ var optionRenderer ;
2475+ var renderLink = function ( props ) {
2476+ return < a { ...props } > Upgrade here!</ a > ;
2477+ } ;
2478+
2479+ var links = [
2480+ { href : '/link' } ,
2481+ { href : '/link2' , target : '_blank' }
2482+ ] ;
2483+
2484+ var ops = [
2485+ { label : 'Disabled' , value : 'disabled' , disabled : true , link : renderLink ( links [ 0 ] ) } ,
2486+ { label : 'Disabled 2' , value : 'disabled_2' , disabled : true , link : renderLink ( links [ 1 ] ) } ,
2487+ { label : 'Enabled' , value : 'enabled' } ,
2488+ ] ;
2489+
2490+ /**
2491+ * Since we don't have access to an actual Location object,
2492+ * this method will test a string (path) by the end of global.window.location.href
2493+ * @param {string } path Ending href path to check
2494+ * @return {Boolean } Whether the location is at the path
2495+ */
2496+ var isNavigated = function ( path ) {
2497+ var window_location = global . window . location . href ;
2498+ return window_location . indexOf ( path , window_location . length - path . length ) !== - 1 ;
2499+ } ;
2500+
2501+ beforeEach ( function ( ) {
2502+
2503+ optionRenderer = function ( option ) {
2504+ return (
2505+ < span > { option . label } { option . link } </ span >
2506+ ) ;
2507+ } ;
2508+
2509+ optionRenderer = sinon . spy ( optionRenderer ) ;
2510+
2511+ instance = createControl ( {
2512+ options : ops ,
2513+ optionRenderer : optionRenderer
2514+ } ) ;
2515+ } ) ;
2516+
2517+ it ( 'disabled option link is still clickable' , function ( ) {
2518+ var selectArrow = React . findDOMNode ( instance ) . querySelector ( '.Select-arrow' ) ;
2519+ TestUtils . Simulate . mouseDown ( selectArrow ) ;
2520+ var options = React . findDOMNode ( instance ) . querySelectorAll ( '.Select-option' ) ;
2521+ var link = options [ 0 ] . querySelector ( 'a' ) ;
2522+ expect ( link , 'to have attributes' , {
2523+ href : links [ 0 ] . href
2524+ } ) ;
2525+
2526+ expect ( isNavigated ( links [ 0 ] . href ) , 'to be false' ) ;
2527+ TestUtils . Simulate . click ( link ) ;
2528+ expect ( isNavigated ( links [ 0 ] . href ) , 'to be true' ) ;
2529+ } ) ;
2530+
2531+ it ( 'disabled option link with target doesn\'t navigate the current window' , function ( ) {
2532+ var selectArrow = React . findDOMNode ( instance ) . querySelector ( '.Select-arrow' ) ;
2533+ TestUtils . Simulate . mouseDown ( selectArrow ) ;
2534+ var options = React . findDOMNode ( instance ) . querySelectorAll ( '.Select-option' ) ;
2535+ var link = options [ 1 ] . querySelector ( 'a' ) ;
2536+ expect ( link , 'to have attributes' , {
2537+ href : links [ 1 ] . href ,
2538+ target : '_blank'
2539+ } ) ;
2540+
2541+ expect ( isNavigated ( links [ 0 ] . href ) , 'to be true' ) ;
2542+ TestUtils . Simulate . click ( link ) ;
2543+ expect ( isNavigated ( links [ 1 ] . href ) , 'to be false' ) ;
2544+ } ) ;
2545+
2546+ } ) ;
2547+
24632548 describe ( 'placeholder' , function ( ) {
24642549
24652550 beforeEach ( function ( ) {
0 commit comments