Skip to content

Commit

Permalink
fix: better comment textarea for mobile (auto-grow + bigger size)
Browse files Browse the repository at this point in the history
  • Loading branch information
vas3k committed Sep 26, 2024
1 parent f4b3a7f commit 5919846
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/static/css/components/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
https://css-tricks.com/16px-or-larger-text-prevents-ios-form-zoom/
*/
font-size: max(1.25rem, 16px);
min-height: 300px;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
placeholder="Напишите ответ..."
ref="textarea"
:value="value"
@input="growTextareaIfNeeded"
@blur="emitCustomBlur"
>
</textarea>
Expand All @@ -29,6 +30,7 @@ export default {
mounted: function() {
this.attachImageListener();
this.focusTextareaIfNeeded(this.focused);
this.growTextareaIfNeeded();
},
watch: {
Expand All @@ -45,6 +47,10 @@ export default {
shouldFocus && this.$refs["textarea"].focus();
});
},
growTextareaIfNeeded: function() {
this.$refs["textarea"].style.height = 'auto';
this.$refs["textarea"].style.height = this.$refs["textarea"].scrollHeight + 'px';
},
attachImageListener: function() {
// we reach outside the current component to get the filepicker. It is not a good practice,
// but we cannot move the text ownership to form because the editor is used in many different contexts
Expand Down

0 comments on commit 5919846

Please sign in to comment.