Skip to content

EspoCRM – Open Source CRM Application

text field: prevent unwanted scroll on enter

Yuri Kuznetsov44b9f604787c
diff --git a/client/src/views/fields/text.js b/client/src/views/fields/text.js
index 85d6bc0eb4..ed8075c0ed 100644
--- a/client/src/views/fields/text.js
+++ b/client/src/views/fields/text.js
@@ -633,6 +633,12 @@ class TextFieldView extends BaseFieldView {
const match = before.match(/(^|\n)( *[-*]|\d+\.)([^\n]*)$/);
if (!match) {
+ // Prevent unwanted scroll applied by the browser on enter.
+ event.preventDefault();
+
+ target.value = before + "\n" + after;
+ target.selectionStart = target.selectionEnd = before.length + 1;
+
return;
}