Skip to content

Commit

Permalink
チャットパレットからエンターで送信時、チャットパレットの選択状態をリセット。
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanasu committed Oct 17, 2023
1 parent 9298d5e commit 33fce2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/app/component/chat-input/chat-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ export class ChatInputComponent implements OnInit, OnDestroy {
}
}

sendChat(event: Partial<KeyboardEvent>) {
focusInput() {
if (!this.textAreaElementRef) return;
this.textAreaElementRef.nativeElement.focus();
}

sendChat(event: Partial<KeyboardEvent>) {
if (event) event.preventDefault();
//if (!this.text.length) return;
if (event && event.keyCode !== 13) return;
Expand Down
2 changes: 1 addition & 1 deletion src/app/component/chat-palette/chat-palette.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
</div>
<div *ngIf="!isEdit" style="flex-grow: 1; height: 0; min-height: 100px;">
<select #chatPlette class="palette" style="overflow-y: auto;" size="5" (focus)="arrowPalette()" (keydown.arrowUp)="moveToInput($event)" (keyup.arrowUp)="arrowPalette()" (keyup.arrowDown)="arrowPalette()" (keydown.enter)="enterPalette(chatPlette.value)" (click)="clickPalette(chatPlette.value)">
<select #chatPlette class="palette" style="overflow-y: auto;" size="5" (focus)="arrowPalette()" (keydown.arrowUp)="moveToInput($event)" (keyup.arrowUp)="arrowPalette()" (keyup.arrowDown)="arrowPalette()" (keydown.enter)="enterPalette(chatPlette.value, $event)" (click)="clickPalette(chatPlette.value)">
<ng-container *ngIf="palette">
<ng-container *ngFor="let palette of palette.getPalette()">
<option *ngIf="filter(palette)" value="{{palette}}" [style.color]="color">{{palette}}</option>
Expand Down
5 changes: 4 additions & 1 deletion src/app/component/chat-palette/chat-palette.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ export class ChatPaletteComponent implements OnInit, OnDestroy {
}
}

enterPalette(line: string) {
enterPalette(line: string, e: Event=null) {
if (!this.chatPletteElementRef.nativeElement) return;
this.text = this.palette.evaluate(line, this.character.rootDataElement);
this.chatInputComponent.sendChat(null);
this.chatInputComponent.focusInput();
this.chatPletteElementRef.nativeElement.selectedIndex = -1;
if (e) e.preventDefault();
}

moveToPalette() {
Expand Down

0 comments on commit 33fce2d

Please sign in to comment.