File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,52 @@ describe('Select', () => {
159159 } , 500 ) ;
160160 } ) ;
161161
162+ it ( 'The select trigger should be blur when the panel is closed.' , async ( ) => {
163+ const wrapper = mount (
164+ {
165+ render ( ) {
166+ return (
167+ < Select
168+ dropdownRender = { ( ) => {
169+ return < input id = "dropdownRenderInput" /> ;
170+ } }
171+ />
172+ ) ;
173+ } ,
174+ } ,
175+ {
176+ sync : false ,
177+ attachTo : 'body' ,
178+ } ,
179+ ) ;
180+ await asyncExpect ( async ( ) => {
181+ await wrapper . find ( '.ant-select-selector' ) . trigger ( 'mousedown' ) ;
182+ await wrapper . find ( '.ant-select-selection-search-input' ) . trigger ( 'focus' ) ;
183+ } ) ;
184+
185+ await asyncExpect ( async ( ) => {
186+ const el = wrapper . find ( '.ant-select' ) ;
187+
188+ expect ( el . classes ( ) ) . toContain ( 'ant-select-focused' ) ;
189+ $$ ( '#dropdownRenderInput' ) [ 0 ] . focus ( ) ;
190+
191+ expect ( el . classes ( ) ) . toContain ( 'ant-select-focused' ) ;
192+
193+ document . body . dispatchEvent (
194+ new MouseEvent ( 'mousedown' , {
195+ bubbles : true ,
196+ cancelable : true ,
197+ view : window ,
198+ } ) ,
199+ ) ;
200+ } , 100 ) ;
201+
202+ await asyncExpect ( async ( ) => {
203+ const el = wrapper . find ( '.ant-select' ) ;
204+ expect ( el . classes ( ) ) . not . toContain ( 'ant-select-focused' ) ;
205+ } , 200 ) ;
206+ } ) ;
207+
162208 describe ( 'Select Custom Icons' , ( ) => {
163209 it ( 'should support customized icons' , ( ) => {
164210 const wrapper = mount ( {
Original file line number Diff line number Diff line change @@ -343,6 +343,14 @@ export default defineComponent({
343343 if ( mergedOpen . value !== nextOpen && ! props . disabled ) {
344344 setInnerOpen ( nextOpen ) ;
345345 props . onDropdownVisibleChange && props . onDropdownVisibleChange ( nextOpen ) ;
346+
347+ if ( ! nextOpen && popupFocused . value ) {
348+ popupFocused . value = false ;
349+ setMockFocused ( false , ( ) => {
350+ focusRef . value = false ;
351+ blurRef . value = false ;
352+ } ) ;
353+ }
346354 }
347355 } ;
348356
You can’t perform that action at this time.
0 commit comments