Skip to content

Commit

Permalink
feat: position cursor at end of term field in modal on open
Browse files Browse the repository at this point in the history
  • Loading branch information
KaanHanGunay authored and hwgilbert16 committed May 4, 2024
1 parent 5ffa14d commit a3754d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/front/src/app/shared/card/card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div class="row row-cols-1 row-cols-md-2">
<div class="col border-end">
<p class="fs-2">Term</p>
<quill-editor [(ngModel)]="changingTerm" (ngModelChange)="editCardEvent.emit()" id="termEditor" class="w-100"></quill-editor>
<quill-editor (onEditorCreated)="focusEditor($event)" [(ngModel)]="changingTerm" (ngModelChange)="editCardEvent.emit()" id="termEditor" class="w-100"></quill-editor>
</div>
<div class="col mt-4 mt-md-0">
<p class="fs-2 pull-right">Definition</p>
Expand Down
6 changes: 6 additions & 0 deletions apps/front/src/app/shared/card/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { BsModalRef, BsModalService } from "ngx-bootstrap/modal";
import { DomSanitizer } from "@angular/platform-browser";
import { ViewportScroller } from "@angular/common";
import { DeviceDetectorService } from "ngx-device-detector";
import Quill from "quill";

@Component({
selector: "scholarsome-card",
Expand Down Expand Up @@ -153,4 +154,9 @@ export class CardComponent implements OnInit, AfterViewInit {
moveCard(direction: number) {
this.moveCardEvent.emit({ index: this.cardIndex, direction });
}

// Set cursor position to end
focusEditor($event: Quill) {
$event.setSelection($event.getLength(), 0);
}
}

0 comments on commit a3754d4

Please sign in to comment.