mvc-ui - rework paste behavior introduced in 388d99cf6f to make it less aggresive. for https://github.com/opnsense/core/issues/7456

To some degree I think always trimming the data isn't the issue, but not being able to paste at cursor position is impractical. this commit re-wires the paste action after trimming the clipboard data (in stead of overwriting the target field).
This commit is contained in:
Ad Schellevis 2024-05-13 09:48:01 +02:00
parent d86142927e
commit 2e010a77de

View File

@ -204,8 +204,11 @@
/* overwrite clipboard paste behavior and trim before paste */
$("input").on('paste', function(e) {
e.preventDefault();
$(this).val(e.originalEvent.clipboardData.getData("text/plain").trim())
let clipboard_data = e.originalEvent.clipboardData.getData("text/plain").trim();
if (clipboard_data.length > 0) {
e.preventDefault();
document.execCommand('insertText', false, clipboard_data);
}
});
});