What could cause a text input to sometimes be un-selectable for mobile browsers?

谁说我不能喝 提交于 2019-12-24 05:48:08

问题


GOAL:
Make a chat-interface wich works on desktop also work on mobile.

PROBLEM:
I've thrown together a chatbot proof-of-concept. Everything is very simple, including the JS & CSS.
While I'm also having a separate issue with CSS, I suspect this issue might be a javascript problem.

I have a div which contains a text input. The div starts out hidden, and becomes visible when a sibling div is clicked.
Additionally (also when the sibling div is clicked), focus is placed on the text-input contained within.
Yet ...the input field is inaccessible/unavailable for some people whe test from mobile browsers.

// close invitiation and open chat
document.getElementById('chatbot-invitation').addEventListener('click', function () {
    hideChatInvitation()
    showChatContainer()
});

function hideChatInvitation() {
    document.getElementById('chatbot-invitation').classList.add('hide');
}

function showChatContainer() {
    document.getElementById('chatbot-inner-wrapper').classList.remove('hide');
    document.getElementById('textInput').focus();
}

EXAMPLE:
http://temp.mosaranch.com/chatbot-tester

QUESTION:
The focus currently works on desktop browsers. Is there something that needs to be done differently for mobile browsers?

来源:https://stackoverflow.com/questions/46434867/what-could-cause-a-text-input-to-sometimes-be-un-selectable-for-mobile-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!