E
E
Evgeny Khripunov2018-08-21 15:21:51
Mobile development
Evgeny Khripunov, 2018-08-21 15:21:51

How not to hide the keyboard on mobile devices when triggering an event in vue?

There is an input field and a button to send a message

<textarea placeholder="Введите сообщение"
          v-model.trim="inputText" v-focus
          @keyup.ctrl.enter="sendMessage"></textarea>
<button @click.prevent="sendMessage"
        :disabled="inputText === null || inputText === ''">
    <img src="..." alt="Отправить">
</button>

sendMessage method:
sendMessage() {
                event.preventDefault();
                if (this.inputText !== null && this.inputText !== "") {
                    let message = this.inputText;
                    this.inputText = null;                   
                    axios.post(...)                        
                }
            },

When opening a page with v-focus, the focus is immediately on the textarea and the keyboard is opened on mobile devices. However, when the button is clicked , the keyboard closes . How to leave the keyboard permanently open ?
Added @click. prevent and event.preventDefault(), but that doesn't help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2018-08-21
@fannyfan414

Try making the textarea focus on button click

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question