Turn on graph-text syncing when palette gets focus

Previously we were turning on graph-text syncing typically when
the text box loses focus (on blur) but that is driven when you
switch browser tabs. This means switching browser tabs and back
again could damage your text (if you were mid-something) even
though you hadn't actually touch the graph canvas. With this
change we only turn on graph-text syncing (and drive the
regeneration of the text from the graph) if you actively
interact with the palette
This commit is contained in:
Andy Clement
2017-11-08 10:06:28 -08:00
parent c8fadb1ba7
commit fdf3b6ffbc
3 changed files with 10 additions and 2 deletions

View File

@@ -4,7 +4,8 @@
<div *ngIf="!noPalette" id="palette-container" class="palette-container" style="overflow:hidden;">
<flo-palette [metamodel]="metamodel" [renderer]="renderer" [paletteSize]="paletteSize"
(onPaletteEntryDrop)="handleDnDFromPalette($event)"
(paletteReady)="updatePaletteReadyState($event)"></flo-palette>
(paletteReady)="updatePaletteReadyState($event)"
(paletteFocus)="graphToTextSync=true"></flo-palette>
</div>
<div id="sidebar-resizer" *ngIf="!noPalette"

View File

@@ -1,5 +1,5 @@
<div id="palette-filter" class="palette-filter">
<input type="text" id="palette-filter-textfield" class="palette-filter-textfield" [(ngModel)]="filterText"/>
<input type="text" id="palette-filter-textfield" class="palette-filter-textfield" [(ngModel)]="filterText" (focus)="onFocus()"/>
</div>
<div id="palette-paper-container" style="height:calc(100% - 40px); width:100%; overflow:auto;">
<div id="palette-paper" class="palette-paper" style="overflow:hidden;"></div>

View File

@@ -85,6 +85,9 @@ export class Palette implements OnInit, OnDestroy, OnChanges {
@Output()
paletteReady = new EventEmitter<boolean>();
@Output()
paletteFocus = new EventEmitter<void>();
private _paletteSize : number;
private _filterText : string = '';
@@ -127,6 +130,10 @@ export class Palette implements OnInit, OnDestroy, OnChanges {
this.closedGroups = new Set<string>();
}
onFocus(): void {
this.paletteFocus.emit();
}
ngOnInit() {
let element = $('#palette-paper', this.element.nativeElement);
// Create the paper for the palette using the specified element view