Wikiki/bulma-tagsinput

Selecting and deleting tags via keys not working in Chrome

Closed this issue · 0 comments

Issue

The following keys are not working with respect to deleting and selecting tags if one uses Chrome (63.0 Developer Build): Backspace, Delete, Left/Right

Possible Fix

Apparently one has to distinguish the behaviour of different browsers regarding the JQuery EventListener Variables keypress, keydown and keyup:
https://stackoverflow.com/questions/4843472/javascript-listener-keypress-doesnt-detect-backspace/4843502

For me it was sufficient to alter tagsinput.js by changing keypress to keydown in
this.input.addEventListener('keypress', (e) => {
to
this.input.addEventListener('keydown', (e) => {
in the enable() function and subsequently hardcoding the keycode 188 of the delimiter , from
if (key === 13 || key === this.options.delimiter.charCodeAt(0) || key === 9)
to
if (key === 13 || key === this.options.delimiter.charCodeAt(0) || key === 188 || key === 9)
since keydown refers to actual key codes, not ascii codes.