From 2e010a77deef8a8decfb559660e892e702426be7 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 13 May 2024 09:48:01 +0200 Subject: [PATCH] mvc-ui - rework paste behavior introduced in https://github.com/opnsense/core/commit/388d99cf6f4ab8387fb463e2e18584c7c2fce982 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). --- src/opnsense/mvc/app/views/layouts/default.volt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/opnsense/mvc/app/views/layouts/default.volt b/src/opnsense/mvc/app/views/layouts/default.volt index 8ef2fee4d..80a8881c8 100644 --- a/src/opnsense/mvc/app/views/layouts/default.volt +++ b/src/opnsense/mvc/app/views/layouts/default.volt @@ -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); + } }); });