@@ -233,6 +233,47 @@ module('DOM Helper: click', function (hooks) {
233
233
assert . verifySteps ( [ 'mousedown' , 'mouseup' , 'click' ] ) ;
234
234
} ) ;
235
235
} ) ;
236
+
237
+ module ( 'focusable and non-focusable elements interaction' , function ( ) {
238
+ test ( 'clicking on non-focusable element triggers blur on active element' , async function ( assert ) {
239
+ element = document . createElement ( 'div' ) ;
240
+
241
+ insertElement ( element ) ;
242
+
243
+ const focusableElement = buildInstrumentedElement ( 'input' ) ;
244
+
245
+ await click ( focusableElement ) ;
246
+ await click ( element ) ;
247
+
248
+ assert . verifySteps ( [ 'mousedown' , 'focus' , 'focusin' , 'mouseup' , 'click' , 'blur' , 'focusout' ] ) ;
249
+ } ) ;
250
+
251
+ test ( 'clicking on focusable element triggers blur on active element' , async function ( assert ) {
252
+ element = document . createElement ( 'input' ) ;
253
+
254
+ insertElement ( element ) ;
255
+
256
+ const focusableElement = buildInstrumentedElement ( 'input' ) ;
257
+
258
+ await click ( focusableElement ) ;
259
+ await click ( element ) ;
260
+
261
+ assert . verifySteps ( [ 'mousedown' , 'focus' , 'focusin' , 'mouseup' , 'click' , 'blur' , 'focusout' ] ) ;
262
+ } ) ;
263
+
264
+ test ( 'clicking on non-focusable element does not trigger blur on non-focusable active element' , async function ( assert ) {
265
+ element = document . createElement ( 'div' ) ;
266
+
267
+ insertElement ( element ) ;
268
+
269
+ const nonFocusableElement = buildInstrumentedElement ( 'div' ) ;
270
+
271
+ await click ( nonFocusableElement ) ;
272
+ await click ( element ) ;
273
+
274
+ assert . verifySteps ( [ 'mousedown' , 'mouseup' , 'click' ] ) ;
275
+ } ) ;
276
+ } ) ;
236
277
} ) ;
237
278
238
279
module ( 'DOM Helper: click with window' , function ( ) {
0 commit comments