From 75873327bb875be6f8dd6ae7216626034e86ac29 Mon Sep 17 00:00:00 2001 From: Akshay Antony Date: Tue, 23 Jan 2024 15:00:04 +0530 Subject: [PATCH] fix: #5824, Chips: Separator by new line doesn't work by pasting value --- components/lib/chips/Chips.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/lib/chips/Chips.js b/components/lib/chips/Chips.js index 2fe2e19f91..b853ca9468 100644 --- a/components/lib/chips/Chips.js +++ b/components/lib/chips/Chips.js @@ -162,6 +162,7 @@ export const Chips = React.memo( const onPaste = (event) => { if (props.separator) { + let separator = props.separator.replace('\\n', '\n').replace('\\r', '\r').replace('\\t', '\t'); let pastedData = (event.clipboardData || window['clipboardData']).getData('Text'); if (props.keyfilter) { @@ -170,7 +171,7 @@ export const Chips = React.memo( if (pastedData) { let values = props.value || []; - let pastedValues = pastedData.split(props.separator); + let pastedValues = pastedData.split(separator); pastedValues = pastedValues.filter((val) => (props.allowDuplicate || values.indexOf(val) === -1) && val.trim().length); values = [...values, ...pastedValues];