Within a container, I have a form section enclosed by a component that remains hidden due to the use of v-if
. Upon clicking a button, the boolean value is toggled, revealing the previously concealed component. At this point, I aim to shift focus to the initial input field within the form.
I attempted utilizing aria-live
without success. It seems that the single-page application (SPA) structure might be hindering the proper registration of these live regions - indicating they need to be registered during page rendering and are less responsive when dynamically injected into the DOM. Although unconfirmed, this speculation led me to assign a class to the target input and attempt to utilize HTMLElement.focus()
.
document.querySelector('.focus')[0].focus();
Unfortunately, this approach also proved ineffective. Is there an explanation for why I am encountering difficulties focusing on an element that has been recently added to the visible page content?