Skip to content

Commit

Permalink
Set default no match template to empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Humphreys committed Jan 30, 2019
1 parent a002f93 commit 7da4d7b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
18 changes: 16 additions & 2 deletions dist/tribute.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Tribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Tribute {
return t.bind(this)
}

return noMatchTemplate
return noMatchTemplate || function () {return ''}.bind(this)
})(noMatchTemplate),

// column to search against in the object
Expand Down
11 changes: 11 additions & 0 deletions src/TributeRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,20 @@ class TributeRange {
targetElement.focus()
}

resetSelection(targetElement, path, offset) {
if (!this.isContentEditable(targetElement)) {
if (targetElement !== this.getDocument().activeElement) {
targetElement.focus();
}
} else {
this.selectElement(targetElement, path, offset);
}
}

replaceTriggerText(text, requireLeadingSpace, hasTrailingSpace, originalEvent, item) {
let context = this.tribute.current
let info = this.getTriggerInfo(true, hasTrailingSpace, requireLeadingSpace, this.tribute.allowSpaces)
this.resetSelection(context.element, context.selectedPath, context.selectedOffset)

// Create the event
let replaceEvent = new CustomEvent('tribute-replaced', {
Expand Down

0 comments on commit 7da4d7b

Please sign in to comment.