From b0a896a10f2f1ca1526c688efab87397366d8471 Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Fri, 17 Jun 2022 16:53:50 +0300 Subject: [PATCH] UX: Skip special paste handling in email-group-user-chooser when maximum is 1 (#17124) `email-group-user-chooser` currently handles paste events to allow users to paste multiple entries at once instead of entering them one by one. This behavior makes sense when the component is used in scenarios where it makes sense to provide multiple entries such as the recipients field when creating a PM. However, for instances where the component accepts only 1 entry, it doesn't make a lot of sense to do custom handling of paste events. This commit makes our paste event handler a NOOP when the component is configured to accept only 1 entry in which case pasting will simply input the value into the component's search field. --- .../addon/components/email-group-user-chooser-filter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser-filter.js b/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser-filter.js index 0d9002751a2..9c03ea8add2 100644 --- a/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser-filter.js +++ b/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser-filter.js @@ -6,6 +6,10 @@ export default MultiSelectFilterComponent.extend({ @action onPaste(event) { + if (this.selectKit.options.maximum === 1) { + return; + } + const data = event.originalEvent.clipboardData; if (!data) {