File tree Expand file tree Collapse file tree 4 files changed +40
-3
lines changed Expand file tree Collapse file tree 4 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,5 @@ module.exports = {
9
9
'react/sort-comp' : 0 ,
10
10
'jsx-a11y/interactive-supports-focus' : 0 ,
11
11
'jsx-a11y/no-autofocus' : 0 ,
12
- 'import/no-extraneous-dependencies' : [ 'error' , { devDependencies : true } ] ,
13
12
} ,
14
13
} ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ Thumbs.db
21
21
node_modules
22
22
.cache
23
23
dist
24
+ debug.tsx
24
25
assets /** /* .css
25
26
build
26
27
lib
Original file line number Diff line number Diff line change @@ -773,11 +773,15 @@ export default function generateSelector<
773
773
setInnerSearchValue ( '' ) ;
774
774
} ;
775
775
776
- // Close dropdown when disabled change
776
+ // Close dropdown & remove focus state when disabled change
777
777
useEffect ( ( ) => {
778
- if ( innerOpen && ! ! disabled ) {
778
+ if ( innerOpen && disabled ) {
779
779
setInnerOpen ( false ) ;
780
780
}
781
+
782
+ if ( disabled ) {
783
+ setMockFocused ( false ) ;
784
+ }
781
785
} , [ disabled ] ) ;
782
786
783
787
// Close will clean up single mode search text
Original file line number Diff line number Diff line change
1
+ import { mount } from 'enzyme' ;
2
+ import React from 'react' ;
3
+ import { act } from 'react-dom/test-utils' ;
4
+ import Select from '../src' ;
5
+
6
+ describe ( 'Select.Focus' , ( ) => {
7
+ it ( 'disabled should reset focused' , ( ) => {
8
+ jest . clearAllTimers ( ) ;
9
+ jest . useFakeTimers ( ) ;
10
+
11
+ jest . clearAllTimers ( ) ;
12
+
13
+ const wrapper = mount ( < Select /> ) ;
14
+
15
+ // Focus
16
+ wrapper . find ( 'input' ) . simulate ( 'focus' ) ;
17
+ act ( ( ) => {
18
+ jest . runAllTimers ( ) ;
19
+ wrapper . update ( ) ;
20
+ } ) ;
21
+ expect ( wrapper . exists ( '.rc-select-focused' ) ) . toBeTruthy ( ) ;
22
+
23
+ // Disabled
24
+ wrapper . setProps ( { disabled : true } ) ;
25
+ act ( ( ) => {
26
+ jest . runAllTimers ( ) ;
27
+ wrapper . update ( ) ;
28
+ } ) ;
29
+ expect ( wrapper . exists ( '.rc-select-focused' ) ) . toBeFalsy ( ) ;
30
+
31
+ jest . useRealTimers ( ) ;
32
+ } ) ;
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments