Skip to content

Commit

Permalink
Merge branch 'yairEO:master' into delete-key-select
Browse files Browse the repository at this point in the history
  • Loading branch information
Massi-X authored Nov 24, 2024
2 parents 16e6788 + c719e25 commit 025ad58
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 20 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -863,9 +863,9 @@ var formElm = document.forms[0]; // just an example
tagify.on('keydown', onTagifyKeyDown)
function onTagifyKeyDown(e){
if( e.key == 'Enter' && // "enter" key pressed
!tagify.state.inputText && // assuming user is not in the middle or adding a tag
!tagify.state.editing // user not editing a tag
if( e.detail.event.key == 'Enter' && // "enter" key pressed
!tagify.state.inputText && // assuming user is not in the middle or adding a tag
!tagify.state.editing // user not editing a tag
){
setTimeout(() => formElm.submit()) // put some buffer to make sure tagify has done with whatever, to be on the safe-side
}
Expand Down Expand Up @@ -1148,9 +1148,9 @@ dropdown.*caseSensitive* | <sub>Boolean</sub> | false
dropdown.*maxItems* | <sub>Number</sub> | 10 | Maximum items to show in the suggestions list
dropdown.*classname* | <sub>String</sub> | `""` | Custom *classname* for the dropdown suggestions list
dropdown.*fuzzySearch* | <sub>Boolean</sub> | true | Enables filtering dropdown items values' by string *containing* and not only *beginning*
dropdown.*sortby* | <sub>String/Function</sub> | | If set as `startsWith` string, the suggestions list will be sorted with matched items which starts with the query shown first, and *exact* matches shown before all.<br><br> If this setting is defined as a `function`, it recieves two arguments: the array of filtered items and the query and it must return an Array.<br><br>(*default sorting order is same as the whitelist's*)
dropdown.*sortby* | <sub>String/Function</sub> | | If set as `startsWith` string, the suggestions list will be sorted with matched items which starts with the query shown first, and *exact* matches shown before all.<br><br> If this setting is defined as a `function`, it receives two arguments: the array of filtered items and the query and it must return an Array.<br><br>(*default sorting order is same as the whitelist's*)
dropdown.*accentedSearch* | <sub>Boolean</sub> | true | Enable searching for <em>accented</em> items in the whitelist without typing exact match (#491)
dropdown.*includeSelectedTags* | <sub>Boolean</sub> | false | Should the suggestions list Include already-selected tags (after filtering)
dropdown.*includeSelectedTags* | <sub>Boolean</sub> | false | Should the suggestions list Include already-selected tags (after filtering), which will be marked with a checkmark `✓`
dropdown.*escapeHTML* | <sub>Boolean</sub> | true | Escapes HTML entities in the suggestions' rendered text
dropdown.*position* | <sub>String</sub> | `"all"` | <ul><li>`manual` - will not render the dropdown, and you would need to do it yourself. [See demo](https://yaireo.github.io/tagify/#section-manual-suggestions)</li><li>`text` - places the dropdown next to the caret</li><li>`input` - places the dropdown next to the input (useful in rare situations)</li><li>`all` - normal, full-width design</li></ul>
dropdown.*RTL* | <sub>Boolean</sub> | false | Dictates the dropdown's horizontal starting position. By default it would be aligned with the left side of the *Tagify* component.
Expand Down
4 changes: 2 additions & 2 deletions dist/tagify.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tagify.esm.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/tagify.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tagify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tagify.polyfills.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yaireo/tagify",
"version": "4.32.0",
"version": "4.32.1",
"homepage": "https://github.com/yairEO/tagify",
"description": "lightweight, efficient Tags input component in Vanilla JS / React / Angular [super customizable, tiny size & top performance]",
"keywords": [
Expand Down
17 changes: 10 additions & 7 deletions src/parts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export default {
onFocusBlur(e){
// when focusing within a tag which is in edit-mode
var _s = this.settings,
nodeTag = isWithinNodeTag.call(this, e.target),
targetIsTagNode = isNodeTag.call(this, e.target),
nodeTag = isWithinNodeTag.call(this, e.relatedTarget),
targetIsTagNode = isNodeTag.call(this, e.relatedTarget),
isTargetXBtn = e.target.classList.contains(_s.classNames.tagX),
isFocused = e.type == 'focusin',
lostFocus = e.type == 'focusout';
Expand All @@ -157,6 +157,10 @@ export default {
// and not the X button or any other custom element thatmight be there
// var tagTextNode = e.target?.closest(this.settings.classNames.tagTextSelector)

if(isTargetXBtn && _s.mode != 'mix') {
this.DOM.input.focus()
}

if( nodeTag && isFocused && (!targetIsTagNode) && !isTargetXBtn) {
this.toggleFocusClass(this.state.hasFocus = +new Date())

Expand Down Expand Up @@ -195,12 +199,13 @@ export default {
// should only loose focus at this point if the event was not generated from within a tag
if( isFocused || nodeTag ) {
this.state.hasFocus = +new Date()
this.toggleFocusClass(this.state.hasFocus)
}
else {
this.state.hasFocus = false;
}

this.toggleFocusClass(this.state.hasFocus)

if( _s.mode == 'mix' ){
if( isFocused ){
this.trigger("focus", eventData)
Expand All @@ -224,7 +229,6 @@ export default {
var dropdownCanBeShown = _s.dropdown.enabled === 0 && !this.state.dropdown.visible,
condition2 = !targetIsTagNode || _s.mode === 'select'

this.toggleFocusClass(true);
this.trigger("focus", eventData)
// e.target.classList.remove('placeholder');
if( dropdownCanBeShown && condition2 ){ // && _s.mode != "select"
Expand Down Expand Up @@ -501,10 +505,9 @@ export default {
}
break
}

case 'Tab' : {
let selectMode = _s.mode == 'select'
if(s && !selectMode) e.preventDefault()
else return true;
return true;
}

case 'Enter' :
Expand Down

0 comments on commit 025ad58

Please sign in to comment.