I'm attempting to verify if an element is currently in focus, specifically an input field, and then apply a class to another element. This is the code I have been working on, but for some reason the hasFocus() function isn't functioning as expected.
onFocus () {
let isFocused = document.el.querySelector('a-input');
let focusedEl = document.el.querySelector('a-button');
if(isFocused.hasFocus()) {
focusedEl.classList.add('testClass');
}
}
I'm trying to implement this functionality within a custom directive in Vue.js.