Skip to content

Commit

Permalink
fix(quicknote): Hide results dropdown when deleting the search symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-wilson-bh authored and jgodi committed Jun 28, 2017
1 parent 9c058ee commit 16f1957
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/elements/quick-note/QuickNote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ describe('Elements: QuickNoteElement', () => {
height: 200
},
keyEnteredByUser: (key: string, keyCode: number): void => {
if (key === 'Backspace') {
this.editorValue = this.editorValue.slice(0, -1);
this.currentWord = this.currentWord.slice(0, -1);
}
// Add the character to the editorValue if it's a character
if (key.length === 1) {
this.editorValue += key;
Expand Down Expand Up @@ -441,6 +445,27 @@ describe('Elements: QuickNoteElement', () => {
expect(mockResults.visible).toBe(false);
}));

it('should hide resultsComponent when @ is backspaced over.', fakeAsync(() => {
ckEditorInstance.valueSetByUser('Note about: ');
ckEditorInstance.keyEnteredByUser('@');
ckEditorInstance.keyEnteredByUser('j');
ckEditorInstance.userPausedAfterEntry();

expect(mockResults.visible).toBe(true);

ckEditorInstance.keyEnteredByUser('Backspace', KeyCodes.BACKSPACE);
ckEditorInstance.keyEnteredByUser('Backspace', KeyCodes.BACKSPACE);
ckEditorInstance.userPausedAfterEntry();

expect(mockResults.visible).toBe(false);

ckEditorInstance.keyEnteredByUser('@');
ckEditorInstance.keyEnteredByUser('j');
ckEditorInstance.userPausedAfterEntry();

expect(mockResults.visible).toBe(true);
}));

it('should handle searching with spaces.', fakeAsync(() => {
ckEditorInstance.valueSetByUser('Note about: ');
ckEditorInstance.keyEnteredByUser('@');
Expand Down
4 changes: 4 additions & 0 deletions src/elements/quick-note/QuickNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ export class QuickNoteElement extends OutsideClick implements OnInit, OnDestroy,
let word = this.getWordAtCursor().trim();
if (this.isTagging) {
let symbol = this.config.triggers[this.taggingMode];
if (!word.includes(symbol)) {
this.hideResults();
return '';
}
word = word.slice(word.indexOf(symbol) + symbol.length);
}
return word;
Expand Down

0 comments on commit 16f1957

Please sign in to comment.