Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> =
// Pasted text should replace back to origin content
if (tokenWithEnter && pastedTextRef.current && /[\r\n]/.test(pastedTextRef.current)) {
// CRLF will be treated as a single space for input element
const replacedText = pastedTextRef.current.replace(/\r\n/g, ' ').replace(/[\r\n]/g, ' ');
const replacedText = pastedTextRef.current
.replace(/[\r\n]+$/, '')
.replace(/\r\n/g, ' ')
.replace(/[\r\n]/g, ' ');
value = value.replace(replacedText, pastedTextRef.current);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Tags.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('Select.Tags', () => {
{
tokenSeparators: ['\r\n'],
clipboardText: '\r\nlight\r\nbamboo\r\n',
inputValue: ' light bamboo ',
inputValue: ' light bamboo',
},
{
tokenSeparators: [' ', '\r\n'],
Expand All @@ -164,7 +164,7 @@ describe('Select.Tags', () => {
{
tokenSeparators: ['\n'],
clipboardText: '\nlight\nbamboo\n',
inputValue: ' light bamboo ',
inputValue: ' light bamboo',
},
].forEach(({ tokenSeparators, clipboardText, inputValue }) => {
it(`paste content to split (${JSON.stringify(tokenSeparators)})`, () => {
Expand Down