Skip to content

Commit

Permalink
fixes #1277 - Delimiter 'spacebar'-key doesn't work correctly - tag i…
Browse files Browse the repository at this point in the history
…s added only after another text input is performed
  • Loading branch information
yairEO committed Jan 11, 2024
1 parent 1453040 commit af15966
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/parts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ export default {
if( _s.mode == 'mix' )
return this.events.callbacks.onMixTagsInput.call(this, e);

var value = this.input.normalize.call(this),
var value = this.input.normalize.call(this, undefined, {trim: false}),
showSuggestions = value.length >= _s.dropdown.enabled,
eventData = {value, inputElm:this.DOM.input},
validation = this.validateTag({value});
Expand All @@ -517,6 +517,7 @@ export default {

eventData.isValid = validation;

console.log(this.state.inputText , value)
// for IE; since IE doesn't have an "input" event so "keyDown" is used instead to trigger the "onInput" callback,
// and so many keys do not change the input, and for those do not continue.
if( this.state.inputText == value ) return;
Expand Down
4 changes: 2 additions & 2 deletions src/tagify.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ Tagify.prototype = {
},

// remove any child DOM elements that aren't of type TEXT (like <br>)
normalize( node ){
normalize( node, options ){
var clone = node || this.DOM.input, //.cloneNode(true),
v = [];

Expand All @@ -730,7 +730,7 @@ Tagify.prototype = {

v = v.replace(/\s/g, ' ') // replace NBSPs with spaces characters

return this.trim(v)
return options?.trim ? this.trim(v) : v
},

/**
Expand Down

0 comments on commit af15966

Please sign in to comment.