Skip to content

Commit

Permalink
Revert "Fix delete key behavior in select mode"
Browse files Browse the repository at this point in the history
This reverts commit 542e73e.
  • Loading branch information
Massi-X committed Nov 24, 2024
1 parent 025ad58 commit 29a8fe9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
5 changes: 0 additions & 5 deletions src/parts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ export default {
// if clicked anywhere else inside a tag, which had triggered an `focusin` event,
// the onFocusBlur should be aborted. This part was spcifically written for `select` mode.
// tagTextNode && this.events.callbacks.onEditTagFocus.call(this, nodeTag)

// this fixes select mode input focus lost, to trigger: Tab into it, delete (backspace) without moving caret
_s.mode == 'select' && this.events.callbacks.onEditTagFocus.call(this, nodeTag)
}

var text = e.target ? this.trim(this.DOM.input.textContent) : '', // a string
Expand Down Expand Up @@ -253,8 +250,6 @@ export default {
// if nothing has changed (same display value), do not add a tag
if( currentDisplayValue === text )
text = ''
else //the input is empty, we should now remove the tag
this.removeTags()
}

shouldAddTags = text && !this.state.actions.selectOption && _s.addTagOnBlur && _s.addTagOn.includes('blur');
Expand Down
7 changes: 1 addition & 6 deletions src/parts/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,9 @@ export default {
tagData = this.suggestedListItems.find(item => (item.value ?? item) == value)

// select mode: reset the dropdown to show all options again to the user
_s.mode == 'select' && setTimeout(() => this.dropdown.show(), 0)

// select mode: after the tag has been removed and focus is lost, trying to click a suggestion (after focusing again) will fail because it tries to replace an inexistent tag
// catch and use addTags() instead. This happens only once
if(_s.mode == 'select' && !this.state.composing && this.userInput) {
this.addTags(value, true)
setTimeout(() => {
closeOnSelect && this.dropdown.hide()
setTimeout(() => closeOnSelect ? this.dropdown.hide() : this.dropdown.show(), 0)
this.DOM.scope.querySelector('.' + _s.classNames.tagText).focus() //set the focus back to input on each select to ensure consistent behavior
}, 0)
return;
Expand Down

0 comments on commit 29a8fe9

Please sign in to comment.