From 8f753a7de3cbc7a1b2fad10efd1c48662e5637f8 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Wed, 16 Oct 2024 20:47:17 -0400 Subject: [PATCH] backspace handling is good now --- .../components/ng-bubbles.component.ts | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/renderer/components/ng-bubbles.component.ts b/src/renderer/components/ng-bubbles.component.ts index 682c69520e..b26e67752b 100644 --- a/src/renderer/components/ng-bubbles.component.ts +++ b/src/renderer/components/ng-bubbles.component.ts @@ -1,16 +1,8 @@ import { Component, forwardRef, - ElementRef, - Optional, - Host, - HostListener, Input, - Output, - ContentChildren, - QueryList, ChangeDetectorRef, - ViewChildren, Renderer2, } from "@angular/core"; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms"; @@ -47,9 +39,9 @@ const removeAt = (arr: any[], index: number) =>
- + + +
export class NgBubblesComponent implements ControlValueAccessor { private onChange = (_: any) => {}; private onTouched = () => {}; - typingState = false; + editingNew = false; editing: boolean[] = []; addables: string[] = []; addableValue: string = ""; @@ -81,10 +73,8 @@ export class NgBubblesComponent implements ControlValueAccessor { this.writeValue(value); } @Input() addable: boolean; - @ViewChildren('bubbleEdit') bubbleEdits: QueryList; constructor( - private element: ElementRef, private changeRef: ChangeDetectorRef, private renderer: Renderer2, ) {} @@ -107,8 +97,8 @@ export class NgBubblesComponent implements ControlValueAccessor { } addLiveItem() { - if (!this.typingState) { - this.typingState = true; + if (!this.editingNew) { + this.editingNew = true; setTimeout(() => { const inputEl = document.querySelector( ".editablePlus", @@ -119,17 +109,20 @@ export class NgBubblesComponent implements ControlValueAccessor { } handleChangeInput(target: EventTarget, index: number) { const newValue = (target as HTMLTextAreaElement).textContent; - if (this.addableValue != newValue) { + if (this.addables[index] != newValue) { this.addables[index] = newValue; + this.changeRef.detectChanges(); } } private transferChangeBubble(index: number) { if(this.addables[index]) { this.changeItem(this.addables[index], index) + this.addables[index]=""; + this.editing[index]=false; + } else { + this.removeItem(index); } - this.addables[index]=""; - this.editing[index]=false; } handleChangeKeypress(event: KeyboardEvent, index: number) { @@ -159,7 +152,7 @@ export class NgBubblesComponent implements ControlValueAccessor { this.changeRef.detectChanges(); } this.addableValue = ""; - this.typingState = false; + this.editingNew = false; } handleKeypress(event: KeyboardEvent) { if (