File tree Expand file tree Collapse file tree 1 file changed +29
-10
lines changed
Expand file tree Collapse file tree 1 file changed +29
-10
lines changed Original file line number Diff line number Diff 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: {
You can’t perform that action at this time.
0 commit comments