Skip to content

Commit c408053

Browse files
committed
updated: moved inline listeners to named method
mostly to be referenced in specs, since i don't know a better way for now.
1 parent 24e16cb commit c408053

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/A11yVueDialogRenderless.vue

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ export default {
114114
this.resetData();
115115
},
116116
117+
/**
118+
* Handle keyboard events on dialoRef element an manage which
119+
* method to call accordingly
120+
*
121+
* @param {Event} e - Javascript keyboard event
122+
*/
123+
handleKeyboard(e) {
124+
if (e.key === 'Escape' && this.role !== 'alertdialog' ) {
125+
this.close(e)
126+
}
127+
128+
if (e.key === 'Tab') {
129+
this.trapFocus(e)
130+
}
131+
},
132+
117133
/**
118134
* @event Close - event for closing the dialog on the parent.
119135
* Internal side-effects are handled in "open" prop watcher
@@ -290,6 +306,17 @@ export default {
290306
} else {
291307
contentRootSiblings.forEach(s => s && s.removeAttribute('aria-hidden'))
292308
}
309+
},
310+
311+
/**
312+
* Internals.
313+
*
314+
* mostly created for testing, because i didn't figure out a
315+
* away of mock funtions that are defined, inline into the scopedSlots
316+
* returned Object
317+
*/
318+
_stopPropagation(e) {
319+
e.stopPropagation()
293320
}
294321
},
295322
@@ -340,16 +367,8 @@ export default {
340367
'aria-labelledby': `${this.id}-title`,
341368
},
342369
listeners: {
343-
click: (e) => e.stopPropagation(),
344-
keydown: (e) => {
345-
if (e.key === 'Escape' && this.role !== 'alertdialog' ) {
346-
this.close(e)
347-
}
348-
349-
if (e.key === 'Tab') {
350-
this.trapFocus(e)
351-
}
352-
}
370+
click: this._stopPropagation,
371+
keydown: this.handleKeyboard
353372
}
354373
},
355374
closeRef: {

0 commit comments

Comments
 (0)