From 61ea631a5e426905847d3fbc737a06687058078f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=E5=B1=8F=E5=B1=B1=E6=9C=80=E9=80=9F=E4=B8=8B?= =?UTF-8?q?=E5=B1=B1=E4=BC=A0=E8=AF=B4?= Date: Mon, 4 Mar 2024 13:38:22 +0800 Subject: [PATCH] =?UTF-8?q?BI-139784=20fix:=20=E3=80=90=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E5=86=85=E6=B5=8BBUG=E3=80=91=E6=95=B0=E6=8D=AE=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去掉首尾的空字符 --- .../multiselect/trigger/editor.multiselect.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/fineui/src/widget/multiselect/trigger/editor.multiselect.js b/packages/fineui/src/widget/multiselect/trigger/editor.multiselect.js index 3391c22a8..896549dfc 100644 --- a/packages/fineui/src/widget/multiselect/trigger/editor.multiselect.js +++ b/packages/fineui/src/widget/multiselect/trigger/editor.multiselect.js @@ -1,4 +1,15 @@ -import { shortcut, Widget, extend, i18nText, createWidget, Controller, isEmptyString, isEmptyArray, BlankSplitChar } from "@/core"; +import { + shortcut, + Widget, + extend, + i18nText, + createWidget, + Controller, + isEmptyString, + isEmptyArray, + BlankSplitChar, + first, last, isNotEmptyString +} from "@/core"; import { StateEditor } from "@/case"; import { SelectPatchEditor } from "./editor/editor.patch"; @@ -77,8 +88,13 @@ export class MultiSelectEditor extends Widget { getKeywords() { const val = this.editor.getValue(); let keywords = val.split(/\u200b\s\u200b/); - if (isEmptyString(keywords[keywords.length - 1])) { - keywords = keywords.slice(0, keywords.length - 1); + if (isEmptyString(first(keywords)) || isEmptyString(last(keywords))) { + keywords = keywords.filter((word, index) => { + if (index === 0 || index === keywords.length - 1) { + return isNotEmptyString(word); + } + return true; + }); } if (/\u200b\s\u200b$/.test(val)) { return keywords.concat([BlankSplitChar]);