-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Textarea for formula #973
Textarea for formula #973
Changes from 15 commits
d9b7d57
6393b27
22f049b
1a7e575
63ac15b
f06eb2c
114a84b
a921e50
e16324a
db4db71
038f714
a7d58e2
9df25ef
bc3be49
43164ae
12c49a3
ba1ade1
2a74483
7877a05
919b425
9e63cbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
document.addEventListener('input', function (event) { | ||
if (event.target && event.target.classList.contains('resize-auto') && event.target.tagName === 'TEXTAREA') { | ||
const textarea = event.target; | ||
textarea.style.overflow = 'hidden'; | ||
textarea.style.resize = 'none'; | ||
textarea.style.height = 'auto'; | ||
textarea.style.height = (textarea.scrollHeight) + 'px'; | ||
} | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. юзай для цього стімулус контроллер There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Досі актуально There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Або навіть видали |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
|
||
export default class extends Controller { | ||
static targets = ["textarea"]; | ||
|
||
connect() { | ||
this.resize(this.element); | ||
} | ||
|
||
resize(textarea) { | ||
textarea.style.overflow = "hidden"; // Prevent scrollbars | ||
textarea.style.resize = "none"; // Prevent manual resizing | ||
textarea.style.height = "auto"; // Reset height | ||
textarea.style.height = `${textarea.scrollHeight}px`; // Adjust height based on scrollHeight | ||
} | ||
|
||
input(event) { | ||
this.resize(event.target); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
<div class="nested-fields"> | ||
<%= f.input :en_label, label: "Formula Label:" %> | ||
<%= f.input :uk_label, label: "Uk Formula Label:" %> | ||
<%= f.input :expression, label: "Formula Expression:" %> | ||
|
||
<%= f.input :expression, as: :text, label: "Formula Expression:", input_html: { | ||
data: { controller: "textarea", action: "input->textarea#input" } | ||
} %> | ||
<%= f.input :uk_unit, label: "Uk Unit Label:" %> | ||
<%= f.input :en_unit, label: "Unit Label:" %> | ||
|
||
<%= link_to_remove_association "- Remove Formula", f, class: "text-red-500 underline" %> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нема строки в кінці файлу