podio / jquery-mentions-input

MIT License
985 stars 333 forks source link

Deleting the whole text only deletes the last character in the buffer #188

Open Dina-Nashaat opened 5 years ago

Dina-Nashaat commented 5 years ago

BUG: If I select all text and then delete with a backspace, only the last character is deleted in the buffer, and the autocomplete still shows with the highlight.

screen shot 2018-12-26 at 1 54 19 am

SOLUTION: Adding a trigger on keyup seems to solve the problem.

add this line in initTextarea (line 97) elmInputBox.bind('keyup', onInputBoxKeyUp); and add a new function (line 392)

        function onInputBoxKeyUp(e) {
            if (e.keyCode === KEY.BACKSPACE) {
                syntaxMessage = getInputBoxValue()
                if(!syntaxMessage){
                    resetBuffer();
                    hideAutoComplete();
                }
                return;
            }
        }