diff options
author | lutangar <johan.dufour@gmail.com> | 2022-08-30 17:13:26 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-09-08 08:41:36 +0200 |
commit | 2873a53efd8913b6b5fbf305320f88731cd07771 (patch) | |
tree | 5063f5b38f222ce27f6923dc4bb8765f713ac4c7 /client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.html | |
parent | 5f016383a4fabf2f296cda6d5e383719ee9d5e27 (diff) | |
download | PeerTube-2873a53efd8913b6b5fbf305320f88731cd07771.tar.gz PeerTube-2873a53efd8913b6b5fbf305320f88731cd07771.tar.zst PeerTube-2873a53efd8913b6b5fbf305320f88731cd07771.zip |
Set scroll position at top of the textarea when opening the subtitle editor.
## Description
This set the position of the scrollbar at the top of the textarea when opening the __subtitle editor__.
Previously the textarea scroll position was at the bottom of the textarea which doesn't make much sense when you want to edit a subtitle : you most likely want to edit the beginning of the subtitle first.
This also set the caret position on the first character.
## Design decision
I had to use a *component approach* instead of an `<ng-template>` for the edition modal because the `@viewChild` directive doesn't work for elements __inside__ an `<ng-template>`.
I needed the `viewChild` directive to get an `ElementRef` of the `textarea`.
> See the following issue and its workaround :
> - https://github.com/valor-software/ngx-bootstrap/issues/3825
> - https://stackblitz.com/edit/angular-t5dfp7
> - https://medium.com/@izzatnadiri/how-to-pass-data-to-and-receive-from-ng-bootstrap-modals-916f2ad5d66e
## Related issues
Closes [peertube-plugin-transcription/#39](https://gitlab.com/apps_education/peertube/plugin-transcription/-/issues/39)
Diffstat (limited to 'client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.html')
-rw-r--r-- | client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.html | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.html b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.html new file mode 100644 index 000000000..e8079c74e --- /dev/null +++ b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal-content/video-caption-edit-modal-content.component.html | |||
@@ -0,0 +1,34 @@ | |||
1 | <ng-container [formGroup]="form"> | ||
2 | <div class="modal-header"> | ||
3 | <h4 i18n class="modal-title">Edit caption</h4> | ||
4 | <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon> | ||
5 | </div> | ||
6 | |||
7 | <div class="modal-body"> | ||
8 | <label i18n for="captionFileContent">Caption</label> | ||
9 | <textarea | ||
10 | id="captionFileContent" | ||
11 | formControlName="captionFileContent" | ||
12 | class="form-control caption-textarea" | ||
13 | [ngClass]="{ 'input-error': formErrors['captionFileContent'] }" | ||
14 | #textarea | ||
15 | > | ||
16 | </textarea> | ||
17 | |||
18 | <div *ngIf="formErrors.captionFileContent" class="form-error"> | ||
19 | {{ formErrors.captionFileContent }} | ||
20 | </div> | ||
21 | </div> | ||
22 | |||
23 | <div class="modal-footer inputs"> | ||
24 | <input | ||
25 | type="button" role="button" i18n-value value="Cancel" class="peertube-button grey-button" | ||
26 | (click)="cancel()" (key.enter)="cancel()" | ||
27 | > | ||
28 | |||
29 | <input | ||
30 | type="submit" i18n-value value="Edit this caption" class="peertube-button orange-button" | ||
31 | [disabled]="!form.valid" (click)="updateCaption()" | ||
32 | > | ||
33 | </div> | ||
34 | </ng-container> | ||