Skip to content

Commit

Permalink
fixed focus problem when changing tabs + removed console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
markellekelly committed Dec 6, 2019
1 parent 95a246d commit ed3262f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 22 additions & 4 deletions packages/celltags/src/addwidget.ts
Expand Up @@ -52,6 +52,7 @@ export class AddWidget extends Widget {
onAfterAttach() {
this.node.addEventListener('mousedown', this);
this.input.addEventListener('keydown', this);
this.input.addEventListener('focus', this);
this.input.addEventListener('blur', this);
}

Expand All @@ -61,6 +62,7 @@ export class AddWidget extends Widget {
onBeforeDetach() {
this.node.removeEventListener('mousedown', this);
this.input.removeEventListener('keydown', this);
this.input.removeEventListener('focus', this);
this.input.removeEventListener('blur', this);
}

Expand All @@ -85,6 +87,9 @@ export class AddWidget extends Widget {
case 'blur':
this._evtBlur();
break;
case 'focus':
this._evtFocus();
break;
default:
break;
}
Expand All @@ -101,14 +106,27 @@ export class AddWidget extends Widget {
this.input.value = '';
this.input.focus();
} else if (event.target !== this.input) {
let value = this.input.value;
(this.parent as TagTool).addTag(value);
this.input.blur();
this._evtBlur();
if (this.input.value !== '') {
let value = this.input.value;
(this.parent as TagTool).addTag(value);
this.input.blur();
this._evtBlur();
}
}
event.preventDefault();
}

/**
* Handle the `'focus'` event for the input box.
*
* @param event - The DOM event sent to the widget
*/
private _evtFocus() {
if (!this.editing) {
this.input.blur();
}
}

/**
* Handle the `'keydown'` event for the input box.
*
Expand Down
2 changes: 0 additions & 2 deletions packages/celltags/src/tool.ts
Expand Up @@ -78,7 +78,6 @@ export class TagTool extends NotebookTools.Tool {
cell.model.metadata.set('tags', tags);
this.refreshTags();
this.loadActiveTags();
console.log(this.tracker.activeCell.model.metadata.get('tags'));
}

/**
Expand All @@ -99,7 +98,6 @@ export class TagTool extends NotebookTools.Tool {
}
this.refreshTags();
this.loadActiveTags();
console.log(this.tracker.activeCell.model.metadata.get('tags'));
}

/**
Expand Down

0 comments on commit ed3262f

Please sign in to comment.