Skip to content

Commit a4f2f4f

Browse files
Fixing positional enter in text area. (#1610)
1 parent 995a7b9 commit a4f2f4f

File tree

1 file changed

+5
-1
lines changed
  • ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/clientlibs/site/js

1 file changed

+5
-1
lines changed

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/textinput/v1/textinput/clientlibs/site/js/textinputview.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@
8787
// Prevent default action of Enter key to avoid form submission
8888
event.preventDefault();
8989
// Append a newline character to the widget value
90-
this.widget.value = this.widget.value + '\n';
90+
let cursorPosition = this.widget.selectionStart;
91+
let textBefore = this.widget.value.substring(0, cursorPosition);
92+
let textAfter = this.widget.value.substring(this.widget.selectionEnd);
93+
this.widget.value = textBefore + '\n' + textAfter;
94+
this.widget.selectionStart = this.widget.selectionEnd = cursorPosition + 1;
9195
}
9296
});
9397
}

0 commit comments

Comments
 (0)