Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete key, focus/blur and dropdown improvements for select mode with userInput #1410

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/parts/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,6 @@ export default {
isMixMode = _s.mode == 'mix',
tagData = this.suggestedListItems.find(item => (item.value ?? item) == value)

// select mode: reset the dropdown to show all options again to the user
if(_s.mode == 'select' && !this.state.composing && this.userInput) {
setTimeout(() => {
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;
}

// The below event must be triggered, regardless of anything else which might go wrong
this.trigger('dropdown:select', {data:tagData, elm, event})

Expand Down Expand Up @@ -332,6 +323,10 @@ export default {
this.toggleFocusClass(true)
})

// select mode: reset the dropdown to show all options again to the user
if(_s.mode == 'select' && !this.state.composing && this.userInput)
setTimeout(() => this.DOM.scope.querySelector('.' + _s.classNames.tagText).focus(), 0) //set the focus back to input on each select to ensure consistent behavior

closeOnSelect && setTimeout(this.dropdown.hide.bind(this))

// execute these tasks once a suggestion has been selected
Expand Down
1 change: 0 additions & 1 deletion src/tagify.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to prevent the dropdown from closing even when closeOnSelect is false

Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ Tagify.prototype = {
this.removeTags(tagElm)

this.trigger("edit:updated", eventData)
this.dropdown.hide()

// check if any of the current tags which might have been marked as "duplicate" should be now un-marked
if( this.settings.keepInvalidTags )
Expand Down