This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,8 @@ export default class DropdownView extends View {
148148
149149 // Open the dropdown panel using the arrow down key, just like with return or space.
150150 this . keystrokes . set ( 'arrowdown' , ( data , cancel ) => {
151- if ( ! this . isOpen ) {
151+ // Don't open if the dropdown is disabled or already open.
152+ if ( this . isEnabled && ! this . isOpen ) {
152153 this . isOpen = true ;
153154 cancel ( ) ;
154155 }
Original file line number Diff line number Diff line change @@ -127,6 +127,8 @@ describe( 'DropdownView', () => {
127127 stopPropagation : sinon . spy ( )
128128 } ;
129129
130+ view . isEnabled = true ;
131+
130132 view . isOpen = true ;
131133 view . keystrokes . press ( keyEvtData ) ;
132134 sinon . assert . notCalled ( keyEvtData . preventDefault ) ;
@@ -140,6 +142,22 @@ describe( 'DropdownView', () => {
140142 expect ( view . isOpen ) . to . be . true ;
141143 } ) ;
142144
145+ it ( 'so "arrowdown" won\'t open the #panelView when #isEnabled is false' , ( ) => {
146+ const keyEvtData = {
147+ keyCode : keyCodes . arrowdown ,
148+ preventDefault : sinon . spy ( ) ,
149+ stopPropagation : sinon . spy ( )
150+ } ;
151+
152+ view . isEnabled = false ;
153+ view . isOpen = false ;
154+
155+ view . keystrokes . press ( keyEvtData ) ;
156+ sinon . assert . notCalled ( keyEvtData . preventDefault ) ;
157+ sinon . assert . notCalled ( keyEvtData . stopPropagation ) ;
158+ expect ( view . isOpen ) . to . be . false ;
159+ } ) ;
160+
143161 it ( 'so "arrowright" is blocked' , ( ) => {
144162 const keyEvtData = {
145163 keyCode : keyCodes . arrowright ,
You can’t perform that action at this time.
0 commit comments