(helper, originalKey)
| 21 | } |
| 22 | |
| 23 | export async function checkFocusBeforePressKey(helper, originalKey) { |
| 24 | if (!helper.options.strict && !store.debugMode) return |
| 25 | if (!Array.isArray(originalKey)) return |
| 26 | |
| 27 | let hasCtrlOrMeta = false |
| 28 | let actionKey = null |
| 29 | for (const k of originalKey) { |
| 30 | if (MODIFIER_PATTERN.test(k)) { |
| 31 | hasCtrlOrMeta = true |
| 32 | } else { |
| 33 | actionKey = k |
| 34 | } |
| 35 | } |
| 36 | if (!hasCtrlOrMeta || !actionKey || !EDITING_KEYS.has(actionKey.toLowerCase())) return |
| 37 | |
| 38 | if (!await isNoElementFocused(helper)) return |
| 39 | |
| 40 | const message = `No element is in focus. Key combination with "${originalKey.join('+')}" may not work as expected. Use I.click() or I.focus() first.` |
| 41 | if (helper.options.strict) throw new NonFocusedType(message) |
| 42 | helper.debugSection('Warning', message) |
| 43 | } |
no test coverage detected