Skip to content

Commit

Permalink
fix: #5824, Chips: Separator by new line doesn't work by pasting value (
Browse files Browse the repository at this point in the history
#5825)

Co-authored-by: Akshay Antony <[email protected]>
  • Loading branch information
akshayaqburst and akshayantony55 authored Jan 23, 2024
1 parent f81cac9 commit 4c6553a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/lib/chips/Chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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];
Expand Down

0 comments on commit 4c6553a

Please sign in to comment.