Skip to content

Commit

Permalink
in normal mode, if there is a single tag and while the dropdown is op…
Browse files Browse the repository at this point in the history
…en the tag's `x` button is clicked, then the component should be re-focused
  • Loading branch information
yairEO committed Nov 23, 2024
1 parent b39985c commit 9743bab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 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 @@ -192,12 +196,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 Down

0 comments on commit 9743bab

Please sign in to comment.