fix(mail(js)): disable autogrow of textarea in popup window

Fixes #4962
pull/270/head
Francis Lachapelle 2020-02-21 11:54:27 -05:00
parent 5e1f487e49
commit daaad938cb
2 changed files with 11 additions and 8 deletions

View File

@ -274,13 +274,13 @@
md-autofocus="::!editor.isNew()"
md-no-resize="md-no-resize"
md-no-autogrow="md-no-autogrow"
sg-autogrow="sg-autogrow"
sg-autogrow="!isPopup"
md-detect-hidden="md-detect-hidden" />
</md-input-container>
</md-dialog-content>
<!-- ATTACHMENTS -->
<md-dialog-content class="md-actions sg-mail-editor-attachments"
<md-dialog-actions class="sg-mail-editor-attachments"
layout="row" layout-align="space-between start">
<!-- Attachments -->
<md-chips ng-model="editor.uploader.queue"
@ -311,7 +311,7 @@
-->
<!-- multiple="multiple" -->
</div>
</md-dialog-content>
</md-dialog-actions>
</form>
<sg-ripple class="md-default-theme md-accent md-bg"

View File

@ -4,26 +4,30 @@
'use strict';
/**
* sgAutogrow - A directive to automatically grow a textarea depending on its content.
* sgAutogrow - A directive to conditionally grow a textarea depending on its content.
* This directive is an alternative to the autogrow feature of the md-input component.
* It fixes the scroll jumping issue described in #3070.
*
* - https://github.com/angular/material/issues/3070
* - https://material.angularjs.org/latest/api/directive/mdInput
*
* The drawback of this simple fix is that it won't shrink the textarea but only
* increase its height. It also requires to set md-no-autogrow.
* The drawback of this directive is that it requires to set md-no-autogrow.
* @memberof SOGo.Common
* @ngInject
* @example:
<textarea rows="9" md-no-autogrow sg-autogrow />
<textarea rows="9" md-no-autogrow sg-autogrow="!isPopup" />
*/
sgAutogrow.$inject = ['$document', '$timeout'];
function sgAutogrow($document, $timeout) {
return {
restrict: 'A',
scope: {
autogrow: '=sgAutogrow'
},
link: function(scope, elem, attr) {
if (!scope.autogrow) return;
var textarea = elem[0];
var hiddenDiv = $document[0].createElement('div');
var content = null;
@ -46,7 +50,6 @@
hiddenDiv.style.visibility = 'hidden';
hiddenDiv.style.display = 'block';
textarea.style.height = hiddenDiv.offsetHeight + 'px';
console.debug('resize to ' + hiddenDiv.offsetHeight + 'px');
hiddenDiv.style.visibility = 'visible';
hiddenDiv.style.display = 'none';
});