keep focus on textarea after button click



  • Please advice how to keep focus on textarea element after clicking q-btn.

    Tried to apply preventDefault

    <q-btn @click.prevent="handleClick" label="click me" />
    

    and stopPropagation

    <q-btn @click.stop="handleClick" label="click me" />
    

    But in any case textarea losses the focus after click. I know that focus can be returned back to textarea using focus() but on mobile it causes side effect like blinking embedded keyboard.

    I can reach desired result by replacing q-btn with simple div and using mousedown event instead of click. Maybe there is a workaround to implement similar behavior with q-btn?

    Codepen: https://codepen.io/olegef/pen/NWNvxJM


Log in to reply