diff --git a/src/addons/mod/glossary/pages/edit/edit.html b/src/addons/mod/glossary/pages/edit/edit.html index b533fdfa0..765701f60 100644 --- a/src/addons/mod/glossary/pages/edit/edit.html +++ b/src/addons/mod/glossary/pages/edit/edit.html @@ -41,7 +41,7 @@ {{ 'addon.mod_glossary.aliases' | translate }} - diff --git a/src/addons/mod/workshop/assessment/accumulative/component/addon-mod-workshop-assessment-strategy-accumulative.html b/src/addons/mod/workshop/assessment/accumulative/component/addon-mod-workshop-assessment-strategy-accumulative.html index 20b6319a1..33cc08a48 100644 --- a/src/addons/mod/workshop/assessment/accumulative/component/addon-mod-workshop-assessment-strategy-accumulative.html +++ b/src/addons/mod/workshop/assessment/accumulative/component/addon-mod-workshop-assessment-strategy-accumulative.html @@ -32,7 +32,8 @@ {{ 'addon.mod_workshop_assessment_accumulative.dimensioncommentfor' | translate : {'$a': field.dimtitle } }} - + + diff --git a/src/addons/mod/workshop/assessment/comments/component/addon-mod-workshop-assessment-strategy-comments.html b/src/addons/mod/workshop/assessment/comments/component/addon-mod-workshop-assessment-strategy-comments.html index fde783cf8..fe2566390 100644 --- a/src/addons/mod/workshop/assessment/comments/component/addon-mod-workshop-assessment-strategy-comments.html +++ b/src/addons/mod/workshop/assessment/comments/component/addon-mod-workshop-assessment-strategy-comments.html @@ -14,7 +14,8 @@ {{ 'addon.mod_workshop_assessment_comments.dimensioncommentfor' | translate : {'$a': field.dimtitle } }} - + + diff --git a/src/addons/mod/workshop/assessment/numerrors/component/addon-mod-workshop-assessment-strategy-numerrors.html b/src/addons/mod/workshop/assessment/numerrors/component/addon-mod-workshop-assessment-strategy-numerrors.html index 2b7a47b80..5449e5872 100644 --- a/src/addons/mod/workshop/assessment/numerrors/component/addon-mod-workshop-assessment-strategy-numerrors.html +++ b/src/addons/mod/workshop/assessment/numerrors/component/addon-mod-workshop-assessment-strategy-numerrors.html @@ -36,7 +36,7 @@ {{ 'addon.mod_workshop_assessment_numerrors.dimensioncommentfor' | translate : {'$a': field.dimtitle } }} + [core-auto-rows]="selectedValues[n].peercomment"> diff --git a/src/core/components/send-message-form/core-send-message-form.html b/src/core/components/send-message-form/core-send-message-form.html index 74fadaad4..a54a9b86c 100644 --- a/src/core/components/send-message-form/core-send-message-form.html +++ b/src/core/components/send-message-form/core-send-message-form.html @@ -4,7 +4,7 @@ [core-auto-focus]="showKeyboard" [placeholder]="placeholder" rows="1" - core-auto-rows + [core-auto-rows]="message" [(ngModel)]="message" name="message" (onResize)="textareaResized()" diff --git a/src/core/directives/auto-rows.ts b/src/core/directives/auto-rows.ts index 00c570e38..ea6318585 100644 --- a/src/core/directives/auto-rows.ts +++ b/src/core/directives/auto-rows.ts @@ -12,41 +12,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Directive, ElementRef, HostListener, Output, EventEmitter, AfterViewInit } from '@angular/core'; +import { Directive, ElementRef, Output, EventEmitter, AfterViewInit, Input, OnChanges } from '@angular/core'; /** * Directive to adapt a textarea rows depending on the input text. It's based on Moodle's data-auto-rows. * * @description * Usage: - * + * */ @Directive({ selector: 'textarea[core-auto-rows], ion-textarea[core-auto-rows]', }) -export class CoreAutoRowsDirective implements AfterViewInit { +export class CoreAutoRowsDirective implements AfterViewInit, OnChanges { protected height = 0; + @Input('core-auto-rows') value?: string; // eslint-disable-line @angular-eslint/no-input-rename @Output() onResize: EventEmitter; // Emit when resizing the textarea. constructor(protected element: ElementRef) { this.onResize = new EventEmitter(); } - @HostListener('input') onInput(): void { - this.resize(); - } - - @HostListener('change') onChange(): void { - // Fired on reset. Wait to the change to be finished. - setTimeout(() => { - this.resize(); - }, 300); - } - /** - * Resize after content. + * Resize after initialized. */ ngAfterViewInit(): void { // Wait for rendering of child views. @@ -55,6 +45,18 @@ export class CoreAutoRowsDirective implements AfterViewInit { }, 300); } + /** + * Resize when content changes. + */ + ngOnChanges(): void { + this.resize(); + + if (this.value === '') { + // Maybe the form was resetted. In that case it takes a bit to update the height. + setTimeout(() => this.resize(), 300); + } + } + /** * Resize the textarea. */